mirror of
https://github.com/hi2shark/nazhua.git
synced 2026-01-14 08:10:42 +08:00
✨ 优化服务器信息框,新增温度数据分类处理及图标显示
This commit is contained in:
parent
48d6e5c36a
commit
bc50b78135
@ -78,8 +78,27 @@
|
||||
class="server-info-item"
|
||||
:class="`temperature--${ttItem.type}`"
|
||||
>
|
||||
<span class="server-info-item-label">
|
||||
{{ ttItem.label }}
|
||||
<span class="server-info-item-icon">
|
||||
<i
|
||||
v-if="ttItem.type === 'cpu' || ttItem.label.toLowerCase().includes('cpu')"
|
||||
class="ri-cpu-line"
|
||||
/>
|
||||
<i
|
||||
v-else-if="ttItem.type === 'gpu' || ttItem.label.toLowerCase().includes('gpu')"
|
||||
class="ri-gamepad-line"
|
||||
/>
|
||||
<i
|
||||
v-else-if="ttItem.type === 'nvme' || ttItem.label.toLowerCase().includes('nvme')"
|
||||
class="ri-hard-drive-3-line"
|
||||
/>
|
||||
<i
|
||||
v-else-if="ttItem.type === 'motherboard'"
|
||||
class="ri-instance-line"
|
||||
/>
|
||||
<i
|
||||
v-else
|
||||
class="ri-temp-hot-line"
|
||||
/>
|
||||
</span>
|
||||
<span class="server-info-item-value">
|
||||
{{ ttItem.value }}
|
||||
@ -326,102 +345,157 @@ const temperatureData = computed(() => {
|
||||
const acpitz = [];
|
||||
const coretemp_package_id = [];
|
||||
const coretemp_core = [];
|
||||
const nvme = [];
|
||||
const k10temp = [];
|
||||
const amdgpu = [];
|
||||
const other = [];
|
||||
|
||||
// 温度数据分类处理
|
||||
props.info.State.Temperatures.forEach((item) => {
|
||||
if (item.Name.indexOf('acpitz') === 0) {
|
||||
acpitz.push(item.Temperature);
|
||||
const name = item.Name.toLowerCase();
|
||||
const temp = item.Temperature;
|
||||
|
||||
if (name.startsWith('acpitz')) {
|
||||
acpitz.push(temp);
|
||||
return;
|
||||
}
|
||||
if (item.Name.indexOf('coretemp_package_id_') === 0) {
|
||||
const coreIndex = parseInt(item.Name.replace('coretemp_package_id_', ''), 10);
|
||||
if (name.startsWith('coretemp_package_id_')) {
|
||||
const coreIndex = parseInt(name.replace('coretemp_package_id_', ''), 10);
|
||||
coretemp_package_id.push({
|
||||
index: coreIndex,
|
||||
value: `${item.Temperature}℃`,
|
||||
value: temp,
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (item.Name.indexOf('coretemp_core_') === 0) {
|
||||
const coreIndex = parseInt(item.Name.replace('coretemp_core_', ''), 10);
|
||||
if (name.startsWith('coretemp_core_')) {
|
||||
const coreIndex = parseInt(name.replace('coretemp_core_', ''), 10);
|
||||
coretemp_core.push({
|
||||
index: coreIndex,
|
||||
value: item.Temperature,
|
||||
value: temp,
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (name.includes('nvme')) {
|
||||
nvme.push({
|
||||
name: item.Name,
|
||||
value: temp,
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (name.includes('k10temp')) {
|
||||
k10temp.push({
|
||||
name: item.Name,
|
||||
value: temp,
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (name.includes('amdgpu')) {
|
||||
amdgpu.push({
|
||||
name: item.Name,
|
||||
value: temp,
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (name.includes('motherboard') || name.includes('mainboard') || name.includes('board')) {
|
||||
other.push({
|
||||
label: '主板',
|
||||
value: temp,
|
||||
type: 'motherboard',
|
||||
});
|
||||
return;
|
||||
}
|
||||
// console.log(item);
|
||||
other.push({
|
||||
label: item.Name,
|
||||
value: `${item.Temperature}℃`,
|
||||
value: temp,
|
||||
type: 'other',
|
||||
});
|
||||
});
|
||||
|
||||
// 主板温度处理
|
||||
if (acpitz.length) {
|
||||
const acpitzMean = (acpitz.reduce((a, b) => a + b, 0) / acpitz.length).toFixed(1);
|
||||
data.push({
|
||||
label: '主板',
|
||||
value: `${acpitz[0]}℃`,
|
||||
type: 'acpitz',
|
||||
value: `${acpitzMean}℃`,
|
||||
title: acpitz.map((i, index) => `传感器${index + 1}: ${parseFloat(i).toFixed(1)}℃`).join('\n'),
|
||||
type: 'motherboard',
|
||||
});
|
||||
if (acpitz.length) {
|
||||
const acpitzMean = (acpitz.reduce((a, b) => a + b, 0) / acpitz.length).toFixed(1) * 1;
|
||||
}
|
||||
|
||||
// CPU温度处理
|
||||
if (coretemp_package_id.length || coretemp_core.length) {
|
||||
const temps = [];
|
||||
const details = [];
|
||||
|
||||
// 处理 CPU 温度
|
||||
if (coretemp_package_id.length) {
|
||||
const cpuTemps = coretemp_package_id.map((i) => `${parseFloat(i.value).toFixed(1)}℃`);
|
||||
temps.push(cpuTemps.join(', '));
|
||||
details.push(...coretemp_package_id.map((i) => `CPU.${i.index + 1}: ${parseFloat(i.value).toFixed(1)}℃`));
|
||||
}
|
||||
|
||||
// 处理核心温度
|
||||
if (coretemp_core.length) {
|
||||
const coreMean = (coretemp_core.reduce((a, b) => a + b.value, 0) / coretemp_core.length).toFixed(1);
|
||||
temps.push(`${parseFloat(coreMean).toFixed(1)}℃`);
|
||||
details.push(...coretemp_core.map((i) => `核心${i.index + 1}: ${parseFloat(i.value).toFixed(1)}℃`));
|
||||
}
|
||||
|
||||
data.push({
|
||||
label: 'CPU',
|
||||
value: temps.join(' / '),
|
||||
title: details.join('\n'),
|
||||
type: 'cpu',
|
||||
});
|
||||
}
|
||||
|
||||
// AMD CPU温度处理
|
||||
if (k10temp.length) {
|
||||
const tctl = k10temp.find((i) => i.name.includes('tctl'));
|
||||
if (tctl) {
|
||||
data.push({
|
||||
label: '主板平均',
|
||||
value: `${acpitzMean}℃`,
|
||||
title: acpitz.map((i, index) => `传感器${index + 1}: ${i}℃`).join('\n'),
|
||||
type: 'acpitz-mean',
|
||||
label: 'AMD CPU',
|
||||
value: `${parseFloat(tctl.value).toFixed(1)}℃`,
|
||||
title: k10temp.map((i) => `${i.name}: ${parseFloat(i.value).toFixed(1)}℃`).join('\n'),
|
||||
type: 'cpu',
|
||||
});
|
||||
}
|
||||
}
|
||||
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) {
|
||||
|
||||
// AMD GPU温度处理
|
||||
if (amdgpu.length) {
|
||||
const edge = amdgpu.find((i) => i.name.includes('edge'));
|
||||
if (edge) {
|
||||
data.push({
|
||||
label: `最热核心.${maxCore + 1}`,
|
||||
value: `${max}℃`,
|
||||
type: 'coretemp-max-core',
|
||||
label: 'AMD GPU',
|
||||
value: `${parseFloat(edge.value).toFixed(1)}℃`,
|
||||
title: amdgpu.map((i) => `${i.name}: ${parseFloat(i.value).toFixed(1)}℃`).join('\n'),
|
||||
type: 'gpu',
|
||||
});
|
||||
}
|
||||
}
|
||||
if (other.length) {
|
||||
// data.push({
|
||||
// type: 'other',
|
||||
// label: '其它',
|
||||
// value: '...',
|
||||
// title: other.map((i) => `${i.label}: ${i.value}`).join('\n'),
|
||||
// });
|
||||
other.forEach((i) => {
|
||||
|
||||
// NVME温度处理
|
||||
if (nvme.length) {
|
||||
const composite = nvme.find((i) => i.name.includes('composite'));
|
||||
if (composite) {
|
||||
data.push({
|
||||
label: i.label,
|
||||
value: i.value,
|
||||
type: 'other',
|
||||
label: 'NVME',
|
||||
value: `${parseFloat(composite.value).toFixed(1)}℃`,
|
||||
title: nvme.map((i) => `${i.name}: ${parseFloat(i.value).toFixed(1)}℃`).join('\n'),
|
||||
type: 'nvme',
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 其他温度处理
|
||||
other.forEach((i) => {
|
||||
data.push({
|
||||
label: i.label,
|
||||
value: `${parseFloat(i.value).toFixed(1)}℃`,
|
||||
type: i.type || 'other',
|
||||
});
|
||||
});
|
||||
}
|
||||
return {
|
||||
list: data,
|
||||
@ -571,6 +645,17 @@ const processCount = computed(() => props.info?.State?.ProcessCount);
|
||||
.server-info-item {
|
||||
display: flex;
|
||||
gap: 0.2em;
|
||||
align-items: center;
|
||||
|
||||
.server-info-item-icon {
|
||||
width: 24px;
|
||||
height: 16px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 16px;
|
||||
color: #ccc;
|
||||
}
|
||||
}
|
||||
|
||||
.server-info-item-value {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user