优化内存显示

This commit is contained in:
CN-JS-HuiBai
2026-04-09 12:47:01 +08:00
parent a14fcdf158
commit 06ddd5a8e1

View File

@@ -1002,6 +1002,15 @@
const getShiftedCoords = (name) => { const getShiftedCoords = (name) => {
const lower = (name || '').toLowerCase().trim(); const lower = (name || '').toLowerCase().trim();
// 优先从当前服务器列表中查找坐标,解决线不从服务器起始的问题
const server = servers.find(s =>
(s.job && s.job.toLowerCase() === lower) ||
(s.instance && s.instance.toLowerCase() === lower)
);
if (server && server.lat && server.lng) {
return [shiftLng(server.lng), server.lat];
}
// 备选从静态预定义的国家/城市坐标库中查找
if (countryCoords[lower]) return [shiftLng(countryCoords[lower][0]), countryCoords[lower][1]]; if (countryCoords[lower]) return [shiftLng(countryCoords[lower][0]), countryCoords[lower][1]];
return null; return null;
}; };
@@ -1175,7 +1184,11 @@
<div style="display: flex; align-items: baseline; gap: 8px;"> <div style="display: flex; align-items: baseline; gap: 8px;">
<span style="font-weight: 700; font-size: 1.1rem;">${formatPercent(server.cpuPercent)}</span> <span style="font-weight: 700; font-size: 1.1rem;">${formatPercent(server.cpuPercent)}</span>
</div>` }, </div>` },
{ key: 'memUsedPct', label: '内存使用率 (RAM)', value: formatPercent(server.memPercent) }, { key: 'memUsedPct', label: '内存使用率 (RAM)', value: `
<div style="display: flex; align-items: baseline; gap: 8px;">
<span style="font-weight: 700; font-size: 1.1rem;">${formatPercent(server.memPercent)}</span>
<span style="font-size: 0.7rem; color: var(--text-secondary); font-weight: normal;">(${formatBytes(server.memUsed)} / ${formatBytes(server.memTotal)})</span>
</div>` },
{ key: 'rootFsUsedPct', label: '根分区使用率 (/)', value: formatPercent(server.diskPercent) }, { key: 'rootFsUsedPct', label: '根分区使用率 (/)', value: formatPercent(server.diskPercent) },
{ key: 'netRx', label: '网络接收速率 (RX)', value: formatBandwidth(server.netRx) }, { key: 'netRx', label: '网络接收速率 (RX)', value: formatBandwidth(server.netRx) },
{ key: 'netTx', label: '网络发送速率 (TX)', value: formatBandwidth(server.netTx) } { key: 'netTx', label: '网络发送速率 (TX)', value: formatBandwidth(server.netTx) }
@@ -1511,7 +1524,11 @@
// Define metrics to show // Define metrics to show
const metrics = [ const metrics = [
{ key: 'cpuBusy', label: 'CPU 使用率', value: cpuValueHtml }, { key: 'cpuBusy', label: 'CPU 使用率', value: cpuValueHtml },
{ key: 'memUsedPct', label: '内存使用率 (RAM)', value: formatPercent(data.memUsedPct) }, { key: 'memUsedPct', label: '内存使用率 (RAM)', value: `
<div style="display: flex; align-items: baseline; gap: 8px;">
<span style="font-weight: 700; font-size: 1.1rem;">${formatPercent(data.memUsedPct)}</span>
<span style="font-size: 0.7rem; color: var(--text-secondary); font-weight: normal;">(${formatBytes(data.memTotal * data.memUsedPct / 100)} / ${formatBytes(data.memTotal)})</span>
</div>` },
{ key: 'swapUsedPct', label: 'SWAP 使用率', value: formatPercent(data.swapUsedPct) }, { key: 'swapUsedPct', label: 'SWAP 使用率', value: formatPercent(data.swapUsedPct) },
{ key: 'rootFsUsedPct', label: '根分区使用率 (/)', value: formatPercent(data.rootFsUsedPct) }, { key: 'rootFsUsedPct', label: '根分区使用率 (/)', value: formatPercent(data.rootFsUsedPct) },
{ key: 'netRx', label: '网络接收速率 (RX)', value: formatBandwidth(data.netRx) }, { key: 'netRx', label: '网络接收速率 (RX)', value: formatBandwidth(data.netRx) },