This commit is contained in:
张成
2025-12-22 16:26:59 +08:00
parent aa2d03ee30
commit e17d5610f5
54 changed files with 11735 additions and 3 deletions

View File

@@ -0,0 +1,48 @@
/**
* 系统信息管理 Mixin
*/
export default {
computed: {
uptime() {
return this.$store ? this.$store.state.system.uptime : '0分钟';
},
cpuUsage() {
return this.$store ? this.$store.state.system.cpuUsage : '0%';
},
memUsage() {
return this.$store ? this.$store.state.system.memUsage : '0MB';
},
deviceId() {
return this.$store ? this.$store.state.system.deviceId : '-';
}
},
methods: {
// 更新运行时间(仅计算,不请求)
startSystemInfoUpdate() {
const updateUptime = () => {
if (this.$store && this.startTime) {
const elapsed = Math.floor((Date.now() - this.startTime) / 1000 / 60);
this.$store.dispatch('system/updateUptime', `${elapsed}分钟`);
}
};
updateUptime();
setInterval(updateUptime, 5000);
},
// 接收主进程推送的系统信息(不做处理,直接更新 store
updateSystemInfo(data) {
if (this.$store && data) {
if (data.cpu !== undefined) {
this.$store.dispatch('system/updateCpuUsage', data.cpu);
}
if (data.memory !== undefined) {
this.$store.dispatch('system/updateMemUsage', data.memory);
}
if (data.deviceId !== undefined) {
this.$store.dispatch('system/updateDeviceId', data.deviceId);
}
}
}
}
};