优化: 资源消耗优化,发布 v0.2.1

This commit is contained in:
2026-06-03 12:11:06 +08:00
parent 36aeef4bb7
commit 2c438e3bb9
9 changed files with 113 additions and 50 deletions

View File

@@ -2,7 +2,6 @@ package internal
import (
"fmt"
"strings"
"charm.land/lipgloss/v2"
"u-tabs/internal/style"
@@ -127,7 +126,7 @@ func (m *Model) wsListLines(g Group, svcs []Workspace, w, listH int) []string {
text := truncateByWidth(paddedTitle+" "+ws.Prompt, remainW)
sty := style.SelStyle
if m.wsFocus != 1 {
sty = lipgloss.NewStyle().Foreground(style.Accent).Bold(true)
sty = style.AccentBoldFg
}
lines = append(lines, sty.Render(padRightByWidth(truncateByWidth(prefix+text, w), w)))
} else {
@@ -147,15 +146,14 @@ func (m *Model) wsListLines(g Group, svcs []Workspace, w, listH int) []string {
func (m *Model) wsDetailLines(svcs []Workspace, w, listH int) []string {
if m.cursor >= len(svcs) {
return []string{lipgloss.NewStyle().Foreground(style.Dim).Render(fitWidth(" ← select to view", w))}
return []string{style.DimFg.Render(fitWidth(" ← select to view", w))}
}
ws := svcs[m.cursor]
sepSty := lipgloss.NewStyle().Foreground(style.BgPanel)
var lines []string
lines = append(lines, style.DetailTitle.Render(fitWidth(" "+ws.Title, w)))
lines = append(lines, sepSty.Render(fitWidth(strings.Repeat("─", w), w)))
lines = append(lines, style.SepFg.Render(fitWidth(sepRunes(w), w)))
rows := []struct {
key string
@@ -173,14 +171,14 @@ func (m *Model) wsDetailLines(svcs []Workspace, w, listH int) []string {
lines = append(lines, style.NormStyle.Render(fitWidth(line, w)))
}
lines = append(lines, sepSty.Render(fitWidth(strings.Repeat("─", w), w)))
lines = append(lines, style.SepFg.Render(fitWidth(sepRunes(w), w)))
hintCmd := "wt"
if !isWindows {
hintCmd = "bash"
}
lines = append(lines, lipgloss.NewStyle().Foreground(style.Accent).Italic(true).Render(fitWidth(" $ "+hintCmd+" → CC @"+ws.Title, w)))
lines = append(lines, lipgloss.NewStyle().Foreground(style.Dim).Render(fitWidth(" [Enter]start [Space]multi", w)))
lines = append(lines, style.AccentItalicFg.Render(fitWidth(" $ "+hintCmd+" → CC @"+ws.Title, w)))
lines = append(lines, style.DimFg.Render(fitWidth(" [Enter]start [Space]multi", w)))
if len(lines) > listH {
lines = lines[:listH]