优化: 品牌升级U-TABS,默认打开历史对话

This commit is contained in:
2026-05-22 16:25:00 +08:00
parent e125ac6088
commit ef32867f10

View File

@@ -39,7 +39,7 @@ type Model struct {
func NewModel() *Model { func NewModel() *Model {
return &Model{ return &Model{
activeGroup: 0, activeGroup: len(Groups), // 默认打开历史对话
selected: make(map[int]bool), selected: make(map[int]bool),
} }
} }
@@ -112,7 +112,7 @@ func (m *Model) handleKey(s string) (*Model, tea.Cmd) {
if s == "1" { if s == "1" {
if m.IsHistoryTab() { if m.IsHistoryTab() {
m.activeGroup = 0 m.activeGroup = 0
m.resetCursor() m.resetCursor()
m.wsFocus = 1 m.wsFocus = 1
} }
return m, nil return m, nil
@@ -120,7 +120,7 @@ func (m *Model) handleKey(s string) (*Model, tea.Cmd) {
if s == "2" { if s == "2" {
if !m.IsHistoryTab() { if !m.IsHistoryTab() {
m.activeGroup = len(Groups) // HISTORY m.activeGroup = len(Groups) // HISTORY
m.resetCursor() m.resetCursor()
m.wsFocus = 1 m.wsFocus = 1
return m, m.onTabSwitch() return m, m.onTabSwitch()
} }
@@ -182,10 +182,6 @@ func (m *Model) handleWorkspaceKey(s string) (*Model, tea.Cmd) {
} else { } else {
return m.launchSelected() return m.launchSelected()
} }
case " ":
if m.wsFocus == 1 {
m.toggleMultiSelect()
}
default: default:
if len(s) == 1 && s[0] >= '0' && s[0] <= '9' { if len(s) == 1 && s[0] >= '0' && s[0] <= '9' {
m.inputBuf += s m.inputBuf += s
@@ -487,14 +483,14 @@ func (m *Model) View() tea.View {
v := tea.NewView(m.render()) v := tea.NewView(m.render())
v.AltScreen = true v.AltScreen = true
v.MouseMode = tea.MouseModeCellMotion v.MouseMode = tea.MouseModeCellMotion
v.WindowTitle = "u-tabs" v.WindowTitle = "U-TABS"
return v return v
} }
// renderTabBar 顶部两个主 tab工作空间 / 历史对话 // renderTabBar 顶部两个主 tab工作空间 / 历史对话
func (m *Model) renderTabBar() string { func (m *Model) renderTabBar() string {
var b strings.Builder var b strings.Builder
b.WriteString(style.TitleStyle.Render(" u-tabs v" + Version + " ")) b.WriteString(style.TitleStyle.Render(" U-TABS "))
sep := style.TabSep.Render(" │ ") sep := style.TabSep.Render(" │ ")
// Tab 1: 工作空间 // Tab 1: 工作空间
@@ -566,7 +562,14 @@ func (m *Model) render() string {
b.WriteString("\n") b.WriteString("\n")
helpParts := m.renderHelp() helpParts := m.renderHelp()
b.WriteString(" " + strings.Join(helpParts, " ")) helpStr := " " + strings.Join(helpParts, " ")
verStr := lipgloss.NewStyle().Foreground(style.Dim).Render("绝尘 v" + Version)
padW := m.width - lipgloss.Width(helpStr) - lipgloss.Width(verStr)
if padW > 0 {
b.WriteString(helpStr + strings.Repeat(" ", padW) + verStr)
} else {
b.WriteString(helpStr + " " + verStr)
}
if hint := ConfigHint(); hint != "" { if hint := ConfigHint(); hint != "" {
b.WriteString("\n" + hint) b.WriteString("\n" + hint)
@@ -577,7 +580,7 @@ func (m *Model) render() string {
func (m *Model) renderHelp() []string { func (m *Model) renderHelp() []string {
if m.IsHistoryTab() { if m.IsHistoryTab() {
return []string{ return []string{
m.fmtHelp("j/k", "sel"), m.fmtHelp("↑↓", "sel"),
m.fmtHelp("←→", "panel"), m.fmtHelp("←→", "panel"),
m.fmtHelp("Enter", "resume"), m.fmtHelp("Enter", "resume"),
m.fmtHelp("f", "star"), m.fmtHelp("f", "star"),
@@ -589,9 +592,8 @@ func (m *Model) renderHelp() []string {
} }
return []string{ return []string{
m.fmtHelp("←→", "col"), m.fmtHelp("←→", "col"),
m.fmtHelp("j/k", "sel"), m.fmtHelp("↑↓", "sel"),
m.fmtHelp("Enter", "run"), m.fmtHelp("Enter", "run"),
m.fmtHelp("Space", "multi"),
m.fmtHelp("2", "history"), m.fmtHelp("2", "history"),
m.fmtHelp("q", "quit"), m.fmtHelp("q", "quit"),
} }