Skip to content

Commit 6ad3a8c

Browse files
committed
update
1 parent 03db91c commit 6ad3a8c

3 files changed

Lines changed: 19 additions & 9 deletions

File tree

‎web/css/app.css‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,6 @@ body.light .gauge-half .needle{background:linear-gradient(var(--text),var(--text
148148
.pill.off:hover{filter:brightness(1.1)}
149149
.virt-pill{--virt:var(--accent);display:inline-flex;align-items:center;justify-content:center;min-width:50px;padding:2px 9px;border-radius:999px;border:1px solid color-mix(in srgb,var(--virt) 42%,var(--border));background:color-mix(in srgb,var(--virt) 14%,var(--bg-alt));color:color-mix(in srgb,var(--virt) 72%,#fff);font-size:12px;font-weight:650;line-height:1.2;letter-spacing:.25px;white-space:nowrap}
150150
body.light .virt-pill{background:color-mix(in srgb,var(--virt) 12%,#fff);color:color-mix(in srgb,var(--virt) 68%,#111827)}
151-
.virt-kvm{--virt:#06b6d4}
152-
.virt-xen{--virt:#8b5cf6}
153-
.virt-vmware{--virt:#f59e0b}
154-
.virt-hyper,.virt-hyper-v{--virt:#10b981}
155151
.node-name{display:inline-block;max-width:160px;overflow:hidden;text-overflow:ellipsis;vertical-align:middle;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:13px;font-weight:750;letter-spacing:.15px;color:var(--text)}
156152
.row-server[data-online="0"] .node-name{color:color-mix(in srgb,var(--text) 72%,var(--text-dim));font-weight:650}
157153
.row-server:hover .node-name{color:var(--accent)}

‎web/index.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<meta name="description" content="云监控,ServerStatus中文版,ServerStatus,ServerStatus cppla" />
77
<title>云监控</title>
88
<link rel="icon" type="image/svg+xml" href="favicon.svg" />
9-
<link rel="stylesheet" href="css/app.css?v=20260707-4" />
9+
<link rel="stylesheet" href="css/app.css?v=20260707-5" />
1010
</head>
1111
<body>
1212
<header class="topbar">
@@ -200,6 +200,6 @@ <h3 id="detailTitle" class="modal-title">节点详情</h3>
200200
<a href="https://github.com/cppla/ServerStatus" target="_blank" rel="noopener">ServerStatus中文版</a>
201201
</footer>
202202

203-
<script src="js/app.js?v=20260707-4" defer></script>
203+
<script src="js/app.js?v=20260707-5" defer></script>
204204
</body>
205205
</html>

‎web/js/app.js‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,24 @@ function protoPill(s){
267267
const proto = m.online ? (s.online4 && s.online6 ? '双栈' : (s.online4 ? 'IPv4' : 'IPv6')) : '离线';
268268
return `<span class="pill ${m.online ? 'on' : 'off'}">${proto}</span>`;
269269
}
270+
const VIRT_PALETTE = ['#06b6d4','#8b5cf6','#10b981','#f59e0b','#3b82f6','#14b8a6','#6366f1','#a855f7','#22c55e','#eab308'];
271+
function stableHash(value){
272+
let hash = 2166136261;
273+
const text = String(value || '').trim().toLowerCase();
274+
for(let i = 0; i < text.length; i++){
275+
hash ^= text.charCodeAt(i);
276+
hash = Math.imul(hash, 16777619);
277+
}
278+
return hash >>> 0;
279+
}
280+
function virtColor(type){
281+
const key = String(type || 'unknown').trim().toLowerCase() || 'unknown';
282+
return VIRT_PALETTE[stableHash(key) % VIRT_PALETTE.length];
283+
}
270284
function virtPill(type){
271-
const text = String(type || '-');
272-
const key = text.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '') || 'unknown';
273-
return `<span class="virt-pill virt-${esc(key)}" title="虚拟化:${esc(text)}">${esc(text)}</span>`;
285+
const raw = String(type ?? '').trim();
286+
const text = raw || '-';
287+
return `<span class="virt-pill" style="--virt:${virtColor(raw)}" title="虚拟化:${esc(text)}">${esc(text)}</span>`;
274288
}
275289
function trafficCaps(s, small){
276290
const m = metrics(s);

0 commit comments

Comments
 (0)