Skip to content

Commit 783d277

Browse files
committed
cpu short
1 parent efb2768 commit 783d277

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

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=20260709-18" />
9+
<link rel="stylesheet" href="css/app.css?v=20260709-19" />
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=20260709-18" defer></script>
203+
<script src="js/app.js?v=20260709-19" defer></script>
204204
</body>
205205
</html>

web/js/app.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,20 @@ function serverSpecLabel(s){
8787
function cpuModelLabel(s){
8888
return String(s?.cpu_model || '').trim();
8989
}
90+
function shortCpuModel(model){
91+
const raw = String(model || '').trim();
92+
if(!raw) return '';
93+
const text = raw
94+
.replace(/\((?:R|TM|C)\)/gi, '')
95+
.replace(/\s+@.*$/g, '')
96+
.replace(/\b(?:CPU|Processor)\b/gi, '')
97+
.replace(/\b\d+\s*-?\s*Core\b/gi, '')
98+
.replace(/\b\d+\s*-?\s*Thread\b/gi, '')
99+
.replace(/\b(?:Intel|AMD)\b/gi, '')
100+
.replace(/\s+/g, ' ')
101+
.trim();
102+
return text || raw;
103+
}
90104
function humanAgo(ts){
91105
if(!ts) return '-';
92106
const sec = Math.max(0, Math.floor(Date.now() / 1000 - Number(ts)));
@@ -592,7 +606,8 @@ function refreshDetail(){
592606
const title = $('detailTitle');
593607
const spec = serverSpecLabel(s);
594608
const cpuModel = cpuModelLabel(s);
595-
title.innerHTML = `${esc(s.name || '-')} 详情${s.os ? `<span class="os-chip${osClass(s.os)}">${esc(osLabel(s.os))}</span>` : ''}${spec ? `<span class="spec-chip" title="CPU 核心 / 总内存">${esc(spec)}</span>` : ''}${cpuModel ? `<span class="cpu-model-chip" title="${esc(cpuModel)}">${esc(cpuModel)}</span>` : ''}`;
609+
const shortModel = shortCpuModel(cpuModel);
610+
title.innerHTML = `${esc(s.name || '-')} 详情${s.os ? `<span class="os-chip${osClass(s.os)}">${esc(osLabel(s.os))}</span>` : ''}${spec ? `<span class="spec-chip" title="CPU 核心 / 总内存">${esc(spec)}</span>` : ''}${cpuModel ? `<span class="cpu-model-chip" title="${esc(cpuModel)}">${esc(shortModel)}</span>` : ''}`;
596611
const modalBox = document.querySelector('#detailModal .modal-box');
597612
if(modalBox){
598613
modalBox.classList.toggle('alert-critical', m.rowLevel === 'critical');

0 commit comments

Comments
 (0)