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