Files
chatlog_alpha/internal/ui/dashboard/dashboard.go
lx1056758714-glitch d18e413df0 Refactor UI layout and add dashboard, logs, sidebar
Replaces the infobar with a new dashboard component, introduces a sidebar for navigation, and adds a logs view for runtime messages. Refactors the main app layout to use a sidebar and content pages, updates menu handling, and improves modularity of UI components. Removes infobar and related code, and adds new files for dashboard, layout, logs, and sidebar.
2025-12-19 15:39:25 +08:00

60 lines
1.1 KiB
Go

package dashboard
import (
"fmt"
"github.com/rivo/tview"
"github.com/sjzar/chatlog/internal/ui/style"
)
type Dashboard struct {
*tview.Table
}
func New() *Dashboard {
d := &Dashboard{
Table: tview.NewTable(),
}
d.SetBorders(false)
d.SetBorder(true)
d.SetTitle(" 状态概览 ")
d.SetBorderColor(style.BorderColor)
d.SetBackgroundColor(style.BgColor)
return d
}
func (d *Dashboard) Update(data map[string]string) {
d.Clear()
row := 0
headerColor := style.InfoBarItemFgColor
keys := []string{
"Account", "PID", "Status", "ExePath",
"Platform", "Version", "Session", "Data Key",
"Image Key", "Data Usage", "Data Dir",
"Work Usage", "Work Dir", "HTTP Server", "Auto Decrypt",
}
for _, key := range keys {
val, ok := data[key]
if !ok {
continue
}
d.SetCell(row, 0, tview.NewTableCell(fmt.Sprintf(" [%s::b]%s", headerColor, key)).
SetAlign(tview.AlignRight).
SetExpansion(1).
SetTextColor(style.FgColor))
d.SetCell(row, 1, tview.NewTableCell(fmt.Sprintf(" %s", val)).
SetAlign(tview.AlignLeft).
SetExpansion(3).
SetTextColor(style.FgColor))
row++
}
}