From 44c0c1651b427ea66afc7cd49018c3b1c926d227 Mon Sep 17 00:00:00 2001 From: hi2hi Date: Wed, 11 Dec 2024 03:19:20 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E8=AF=A6=E6=83=85=E9=A1=B5?= =?UTF-8?q?=E6=B8=A9=E5=BA=A6=E6=98=BE=E7=A4=BA=EF=BC=88=E7=9B=AE=E5=89=8D?= =?UTF-8?q?=E4=BB=85=E5=8C=B9=E9=85=8D=E4=B8=BB=E6=9D=BF=E3=80=81CPU?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server-detail/server-info-box.vue | 130 ++++++++++++++++++ 1 file changed, 130 insertions(+) diff --git a/src/views/components/server-detail/server-info-box.vue b/src/views/components/server-detail/server-info-box.vue index eb7488d..b4fafc3 100644 --- a/src/views/components/server-detail/server-info-box.vue +++ b/src/views/components/server-detail/server-info-box.vue @@ -59,6 +59,28 @@ +
+
+ 温度 +
+
+
+ + {{ ttItem.label }} + {{ ttItem.value }} + +
+
+
系统 @@ -274,6 +296,107 @@ const sysLoadInfo = computed(() => { return '-'; }); +const temperatureData = computed(() => { + const data = []; + if (props.info?.State?.Temperatures) { + const acpitz = []; + const coretemp_package_id = []; + const coretemp_core = []; + const other = []; + props.info.State.Temperatures.forEach((item) => { + if (item.Name.indexOf('acpitz') === 0) { + acpitz.push(item.Temperature); + return; + } + if (item.Name.indexOf('coretemp_package_id_') === 0) { + const coreIndex = parseInt(item.Name.replace('coretemp_package_id_', ''), 10); + coretemp_package_id.push({ + index: coreIndex, + value: `${item.Temperature}℃`, + }); + return; + } + if (item.Name.indexOf('coretemp_core_') === 0) { + const coreIndex = parseInt(item.Name.replace('coretemp_core_', ''), 10); + coretemp_core.push({ + index: coreIndex, + value: item.Temperature, + }); + return; + } + // console.log(item); + other.push({ + label: item.Name, + value: `${item.Temperature}℃`, + }); + }); + + if (acpitz.length) { + data.push({ + label: '主板', + value: `${acpitz[0]}℃`, + type: 'acpitz', + }); + if (acpitz.length) { + const acpitzMean = (acpitz.reduce((a, b) => a + b, 0) / acpitz.length).toFixed(1) * 1; + data.push({ + label: '主板平均', + value: `${acpitzMean}℃`, + title: acpitz.map((i, index) => `传感器${index + 1}: ${i}℃`).join('\n'), + type: 'acpitz-mean', + }); + } + } + if (coretemp_package_id.length) { + data.push({ + label: 'CPU温度', + value: coretemp_package_id.map((i) => i.value).join(', '), + title: coretemp_package_id.length > 1 + ? coretemp_package_id.map((i) => `CPU.${i.index + 1}: ${i.value}`).join('\n') + : '', + type: 'coretemp-package', + }); + } + if (coretemp_core.length) { + const coretempCoreMean = (coretemp_core.reduce((a, b) => a + b.value, 0) / coretemp_core.length).toFixed(1) * 1; + data.push({ + label: '核心平均', + value: `${coretempCoreMean}℃`, + title: coretemp_core.map((i) => `核心${i.index + 1}: ${i.value}℃`).join('\n'), + type: 'coretemp-core', + }); + // 最高温度的核心 + let max; + let maxCore; + coretemp_core.forEach((i) => { + if (max === undefined || i.value > max) { + max = i.value; + maxCore = i.index; + } + }); + // 当最高温度的核心温度比平均温度高 20% 时,显示 + if (max / coretempCoreMean > 1.2) { + data.push({ + label: `最热核心.${maxCore + 1}`, + value: `${max}℃`, + type: 'coretemp-max-core', + }); + } + } + if (other.length) { + data.push({ + type: 'other', + label: '其它', + value: '...', + title: other.map((i) => `${i.label}: ${i.value}`).join('\n'), + }); + } + } + return { + list: data, + }; +}); + const { billAndPlan, } = handleServerBillAndPlan({ @@ -392,6 +515,13 @@ const processCount = computed(() => props.info?.State?.ProcessCount); justify-content: flex-end; flex-wrap: wrap; gap: 0 12px; + + &.temperature--other { + // 移动端不显示 + @media screen and (max-width: 768px) { + display: none; + } + } } .server-info-item {