Compare commits
2 Commits
7ff0973a5b
...
2377530fab
| Author | SHA1 | Date | |
|---|---|---|---|
| 2377530fab | |||
| 6605adaed5 |
+55
-64
@@ -549,10 +549,7 @@ func (m model) viewMonitor() string {
|
||||
if tw < 60 {
|
||||
tw = 60
|
||||
}
|
||||
th := m.h
|
||||
if th < 20 {
|
||||
th = 20
|
||||
}
|
||||
innerW := tw - 4
|
||||
|
||||
// ── 顶栏 ──
|
||||
wsDot := "○"
|
||||
@@ -572,47 +569,28 @@ func (m model) viewMonitor() string {
|
||||
)
|
||||
sep := stDim.Render(strings.Repeat("─", tw))
|
||||
|
||||
// ── 列宽计算 ──
|
||||
gap := 2
|
||||
var leftW, rightW int
|
||||
if tw >= 100 {
|
||||
leftW = (tw - gap) / 2
|
||||
rightW = tw - gap - leftW
|
||||
} else {
|
||||
leftW = tw
|
||||
rightW = tw
|
||||
gap = 0
|
||||
}
|
||||
innerL := leftW - 4
|
||||
innerR := rightW - 4
|
||||
|
||||
// ── 左列: CPU + History ──
|
||||
cpuBox := m.viewCPUBox(innerL)
|
||||
histBox := m.viewHistBox(innerL)
|
||||
leftCol := lipgloss.JoinVertical(lipgloss.Left, cpuBox, "", histBox)
|
||||
|
||||
// ── 右列: Memory + GPU ──
|
||||
memBox := m.viewMemBox(innerR)
|
||||
gpuBox := m.viewGPUBox(innerR)
|
||||
rightCol := lipgloss.JoinVertical(lipgloss.Left, memBox, "", gpuBox)
|
||||
|
||||
// ── 合并列 ──
|
||||
var mainContent string
|
||||
if gap > 0 {
|
||||
mainContent = lipgloss.JoinHorizontal(lipgloss.Top,
|
||||
leftCol, strings.Repeat(" ", gap), rightCol,
|
||||
)
|
||||
} else {
|
||||
mainContent = lipgloss.JoinVertical(lipgloss.Left, leftCol, "", rightCol)
|
||||
}
|
||||
|
||||
// ── 底栏 ──
|
||||
footer := stDim.Render(" q 退出 · r 重新配置 · 连接: " + m.cfg.Server)
|
||||
// ── 内容:全部垂直排列 ──
|
||||
cpuBox := m.viewCPUBox(innerW)
|
||||
memBox := m.viewMemBox(innerW)
|
||||
histBox := m.viewHistBox(innerW)
|
||||
gpuBox := m.viewGPUBox(innerW)
|
||||
|
||||
full := lipgloss.JoinVertical(lipgloss.Left,
|
||||
header, sep, "", mainContent, "", sep, footer,
|
||||
header, sep, "",
|
||||
cpuBox, "",
|
||||
memBox, "",
|
||||
histBox, "",
|
||||
gpuBox, "",
|
||||
sep,
|
||||
stDim.Render(" q 退出 · r 重新配置 · 连接: "+m.cfg.Server),
|
||||
)
|
||||
return lipgloss.Place(tw, th, lipgloss.Left, lipgloss.Top, full)
|
||||
|
||||
// 截断到终端高度,防止滚动
|
||||
lines := strings.Split(full, "\n")
|
||||
if len(lines) > m.h {
|
||||
lines = lines[:m.h]
|
||||
}
|
||||
return strings.Join(lines, "\n")
|
||||
}
|
||||
|
||||
// ── CPU 盒子 ──
|
||||
@@ -1212,7 +1190,7 @@ func tryNvidiaSMI() []GPUInfo {
|
||||
var gpus []GPUInfo
|
||||
for _, line := range strings.Split(strings.TrimSpace(string(out)), "\n") {
|
||||
parts := strings.Split(line, ",")
|
||||
if len(parts) < 11 {
|
||||
if len(parts) < 9 {
|
||||
continue
|
||||
}
|
||||
for i := range parts {
|
||||
@@ -1220,27 +1198,40 @@ func tryNvidiaSMI() []GPUInfo {
|
||||
parts[i] = strings.Trim(parts[i], "[]")
|
||||
}
|
||||
|
||||
fan := parseFloatSafe(parts[10])
|
||||
power := parseFloatSafe(parts[9])
|
||||
powerLimit := parseFloatSafe(parts[10])
|
||||
|
||||
gpus = append(gpus, GPUInfo{
|
||||
Name: parts[1],
|
||||
VRAMTotalMB: parseFloat(parts[2]),
|
||||
VRAMUsedMB: parseFloat(parts[3]),
|
||||
Temperature: parseFloat(parts[5]),
|
||||
LoadPercent: parseFloat(parts[6]),
|
||||
CoreClock: parseFloat(parts[7]),
|
||||
MemClock: parseFloat(parts[8]),
|
||||
Power: power,
|
||||
PowerLimit: powerLimit,
|
||||
FanSpeed: fan,
|
||||
PState: cleanStr(parts[12]),
|
||||
Persistence: cleanStr(parts[13]),
|
||||
ComputeMode: cleanStr(parts[14]),
|
||||
DriverVersion: cleanStr(parts[15]),
|
||||
CudaVersion: cleanStr(parts[16]),
|
||||
})
|
||||
g := GPUInfo{
|
||||
Name: parts[1],
|
||||
VRAMTotalMB: parseFloat(parts[2]),
|
||||
VRAMUsedMB: parseFloat(parts[3]),
|
||||
Temperature: parseFloat(parts[5]),
|
||||
LoadPercent: parseFloat(parts[6]),
|
||||
CoreClock: parseFloat(parts[7]),
|
||||
MemClock: parseFloat(parts[8]),
|
||||
}
|
||||
if len(parts) > 9 {
|
||||
g.Power = parseFloatSafe(parts[9])
|
||||
}
|
||||
if len(parts) > 10 {
|
||||
g.PowerLimit = parseFloatSafe(parts[10])
|
||||
}
|
||||
if len(parts) > 11 {
|
||||
g.FanSpeed = parseFloatSafe(parts[11])
|
||||
}
|
||||
if len(parts) > 12 {
|
||||
g.PState = cleanStr(parts[12])
|
||||
}
|
||||
if len(parts) > 13 {
|
||||
g.Persistence = cleanStr(parts[13])
|
||||
}
|
||||
if len(parts) > 14 {
|
||||
g.ComputeMode = cleanStr(parts[14])
|
||||
}
|
||||
if len(parts) > 15 {
|
||||
g.DriverVersion = cleanStr(parts[15])
|
||||
}
|
||||
if len(parts) > 16 {
|
||||
g.CudaVersion = cleanStr(parts[16])
|
||||
}
|
||||
gpus = append(gpus, g)
|
||||
}
|
||||
return gpus
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
.pdot { position:absolute; top:50%; left:50%; width:8px; height:8px; margin:-4px; background:var(--accent); border-radius:50% }
|
||||
@keyframes pulse { 0%{transform:scale(.35);opacity:1} 100%{transform:scale(2.4);opacity:0} }
|
||||
|
||||
.device-grid { padding:12px 20px 32px; display:grid; grid-template-columns:repeat(auto-fill,minmax(420px,1fr)); gap:12px }
|
||||
.device-grid { padding:12px 20px 32px; display:grid; grid-template-columns:repeat(auto-fill,minmax(360px,1fr)); gap:12px }
|
||||
.device-grid > .device-card { min-width:0 }
|
||||
.device-card { background:var(--card); border:1px solid var(--border); border-radius:10px; transition:opacity .3s,border-color .2s,box-shadow .2s }
|
||||
.device-card:hover { border-color:#28304a; box-shadow:0 4px 24px rgba(0,0,0,.2) }
|
||||
|
||||
Reference in New Issue
Block a user