From bd6be58eb48591ac6e7ff07abca6ff3cac70b9cd Mon Sep 17 00:00:00 2001 From: lxb <1580622474@qq.com> Date: Thu, 5 Dec 2024 19:19:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86cpu=E7=9A=84?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/js/script.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/web/js/script.js b/web/js/script.js index c4e9e7e..54da40b 100644 --- a/web/js/script.js +++ b/web/js/script.js @@ -96,7 +96,6 @@ function displayServerData(data){ serverName.textContent = serverTitle + " - Not update -"; } - console.log(serverData); // 网速 if ('network_list' in serverData){ let networkInfo = document.createElement('div'); @@ -120,6 +119,24 @@ function displayServerData(data){ // 分割线 add_bar(serverCard); } + + // CPU + if ('cpu' in serverData){ + let cpuInfo = document.createElement('div'); + cpuInfo.className = 'cpu-info'; + + temperature_list_str = ""; + serverData.cpu['temperature_list'].forEach(function(v){ + temperature_list_str += v + " ℃ "; + }); + cpuInfo.innerHTML = "CPU型号 : " + serverData.cpu['name'] + "
" + + "温度 : " + temperature_list_str + "
" + + "占用率 : " + serverData.cpu['core_avg_occupy'] + "%"; + + serverCard.appendChild(cpuInfo); + // 分割线 + add_bar(serverCard); + } // 内存 if ('memory' in serverData){ @@ -194,7 +211,7 @@ function displayServerData(data){ // 添加进程信息 let processInfo = document.createElement('div'); processInfo.classList.add('process-info'); - processInfo.innerHTML = "使用情况:"; + processInfo.innerHTML = "使用情况: "; gpu.process_list.sort((a, b) => b.memory - a.memory); gpu.process_list.forEach(function(item, index){