From 823a07d46416cb033fa6bd1bd255e17642297376 Mon Sep 17 00:00:00 2001 From: imengying Date: Sun, 13 Sep 2026 00:43:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=E5=8D=A1=E7=89=87?= =?UTF-8?q?=20CPU=20=E6=A0=87=E7=AD=BE=E6=97=81=E6=98=BE=E7=A4=BA=E6=A0=B8?= =?UTF-8?q?=E5=BF=83=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cpu_cores 已随遥测上报并入库,卡片此前未使用。标签显示为 "CPU N 核"(英文 "CPU N cores"),核心数缺失或为 0 时回退为 "CPU"。标签行加 white-space: nowrap,防止长标签在窄卡换行 破坏行高一致性。 --- frontend/src/components/NodeCard.tsx | 3 ++- frontend/src/styles/dashboard.css | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/NodeCard.tsx b/frontend/src/components/NodeCard.tsx index bc01f44..1af8dab 100644 --- a/frontend/src/components/NodeCard.tsx +++ b/frontend/src/components/NodeCard.tsx @@ -104,6 +104,7 @@ export const NodeCard = memo(function NodeCard({ server, config, liveLatencyResu }) { const threshold = config.offline_threshold_seconds; const online = isOnline(server, threshold); + const cpuCores = Math.max(0, Math.trunc(number(server.cpu_cores))); const memory = percent(server.mem_used, server.mem_total); const disk = percent(server.disk_used, server.disk_total); const usedTraffic = trafficUsed(server); @@ -135,7 +136,7 @@ export const NodeCard = memo(function NodeCard({ server, config, liveLatencyResu
- + 0 ? ui(locale, `CPU ${cpuCores} 核`, `CPU ${cpuCores} ${cpuCores === 1 ? "core" : "cores"}`) : "CPU"} value={`${number(server.cpu).toFixed(1)}%`} used={number(server.cpu)} sub={`${number(server.load1).toFixed(2)}, ${number(server.load5).toFixed(2)}, ${number(server.load15).toFixed(2)}`} muted={!online} /> 0 ? `${traffic.toFixed(1)}%` : "∞"} used={traffic} sub={`${formatBytes(usedTraffic)} / ${server.traffic_limit > 0 ? formatBytes(server.traffic_limit) : "∞"}`} muted={!online} /> diff --git a/frontend/src/styles/dashboard.css b/frontend/src/styles/dashboard.css index 531a169..8fbe808 100644 --- a/frontend/src/styles/dashboard.css +++ b/frontend/src/styles/dashboard.css @@ -71,7 +71,7 @@ .metric { display: flex; min-width: 0; flex-direction: column; gap: 4px; } .metric.muted { opacity: .55; } /* 固定行高:CJK 回退字体的 normal 行高大于拉丁文本,浮动行高会把进度条与下一行顶偏 */ -.metric > div { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; line-height: 16px; } +.metric > div { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; line-height: 16px; white-space: nowrap; } .metric span, .metric small { color: var(--muted-foreground); } .metric strong { font-weight: 500; font-variant-numeric: tabular-nums; } .metric small { overflow: hidden; font-size: 12px; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; line-height: 14px; }