diff --git a/frontend/src/pages/HostMonitor.tsx b/frontend/src/pages/HostMonitor.tsx index 0a7ac78..9f39d68 100644 --- a/frontend/src/pages/HostMonitor.tsx +++ b/frontend/src/pages/HostMonitor.tsx @@ -100,13 +100,14 @@ export function HostMonitor() { const m = urlHost ? list.find((h: any) => h.hostname === urlHost) : null; setSelectedHost(m?.hostname || list[0]?.hostname || ''); } - const cur = list.find((h: any) => h.hostname === (urlHost || selectedHost)); + // 切换主机时同步更新 latest / serverInfo + const cur = list.find((h: any) => h.hostname === (selectedHost || urlHost)); if (cur) { setLatest(cur); setServerInfo(cur); } }).catch(() => {}).finally(() => setLoading(false)); - }, []); + }, [selectedHost]); // 加载历史数据 useEffect(() => { @@ -392,8 +393,8 @@ export function HostMonitor() {
- {p.used_gb?.toFixed(1) || p.used || '?'}/{p.total_gb?.toFixed(0) || p.total || '?'}GB - {p.usage_percent || p.used_percent || 0}% + {(p.used_gb ?? 0).toFixed(1)}/{(p.total_gb ?? 0).toFixed(0)}GB + {(p.usage_percent ?? p.used_percent ?? 0).toFixed(1)}%
))}