优化: 资源消耗优化,发布 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

@@ -222,11 +222,19 @@ func (m *Model) moveHistorySess(dir int) {
func (m *Model) currentSessions() []*Session {
if m.history.DirCursor == 0 {
var all []*Session
for _, pd := range m.history.Projects {
all = append(all, pd.Sessions...)
if m.allSessionsDirty || m.allSessionsCache == nil {
total := 0
for _, pd := range m.history.Projects {
total += len(pd.Sessions)
}
all := make([]*Session, 0, total)
for _, pd := range m.history.Projects {
all = append(all, pd.Sessions...)
}
m.allSessionsCache = all
m.allSessionsDirty = false
}
return all
return m.allSessionsCache
}
if m.history.DirCursor == 1 {
return collectFavorites(m.history.Projects, m.history.Favorites)