cpu short

This commit is contained in:
cppla
2026-07-09 17:07:59 +08:00
parent efb2768fa8
commit 783d27732d
2 changed files with 18 additions and 3 deletions
+2 -2
View File
@@ -6,7 +6,7 @@
<meta name="description" content="云监控,ServerStatus中文版,ServerStatus,ServerStatus cppla" />
<title>云监控</title>
<link rel="icon" type="image/svg+xml" href="favicon.svg" />
<link rel="stylesheet" href="css/app.css?v=20260709-18" />
<link rel="stylesheet" href="css/app.css?v=20260709-19" />
</head>
<body>
<header class="topbar">
@@ -200,6 +200,6 @@
<a href="https://github.com/cppla/ServerStatus" target="_blank" rel="noopener">ServerStatus中文版</a>
</footer>
<script src="js/app.js?v=20260709-18" defer></script>
<script src="js/app.js?v=20260709-19" defer></script>
</body>
</html>
+16 -1
View File
@@ -87,6 +87,20 @@ function serverSpecLabel(s){
function cpuModelLabel(s){
return String(s?.cpu_model || '').trim();
}
function shortCpuModel(model){
const raw = String(model || '').trim();
if(!raw) return '';
const text = raw
.replace(/\((?:R|TM|C)\)/gi, '')
.replace(/\s+@.*$/g, '')
.replace(/\b(?:CPU|Processor)\b/gi, '')
.replace(/\b\d+\s*-?\s*Core\b/gi, '')
.replace(/\b\d+\s*-?\s*Thread\b/gi, '')
.replace(/\b(?:Intel|AMD)\b/gi, '')
.replace(/\s+/g, ' ')
.trim();
return text || raw;
}
function humanAgo(ts){
if(!ts) return '-';
const sec = Math.max(0, Math.floor(Date.now() / 1000 - Number(ts)));
@@ -592,7 +606,8 @@ function refreshDetail(){
const title = $('detailTitle');
const spec = serverSpecLabel(s);
const cpuModel = cpuModelLabel(s);
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>` : ''}`;
const shortModel = shortCpuModel(cpuModel);
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>` : ''}`;
const modalBox = document.querySelector('#detailModal .modal-box');
if(modalBox){
modalBox.classList.toggle('alert-critical', m.rowLevel === 'critical');