42 lines
871 B
JavaScript
42 lines
871 B
JavaScript
/**
|
|
* 系统信息状态管理
|
|
*/
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
uptime: '0分钟',
|
|
cpuUsage: '0%',
|
|
memUsage: '0MB',
|
|
deviceId: '-'
|
|
},
|
|
mutations: {
|
|
SET_UPTIME(state, uptime) {
|
|
state.uptime = uptime;
|
|
},
|
|
SET_CPU_USAGE(state, usage) {
|
|
state.cpuUsage = usage;
|
|
},
|
|
SET_MEM_USAGE(state, usage) {
|
|
state.memUsage = usage;
|
|
},
|
|
SET_DEVICE_ID(state, deviceId) {
|
|
state.deviceId = deviceId || '-';
|
|
}
|
|
},
|
|
actions: {
|
|
updateUptime({ commit }, uptime) {
|
|
commit('SET_UPTIME', uptime);
|
|
},
|
|
updateCpuUsage({ commit }, usage) {
|
|
commit('SET_CPU_USAGE', `${usage.toFixed(1)}%`);
|
|
},
|
|
updateMemUsage({ commit }, usage) {
|
|
commit('SET_MEM_USAGE', `${usage}MB`);
|
|
},
|
|
updateDeviceId({ commit }, deviceId) {
|
|
commit('SET_DEVICE_ID', deviceId);
|
|
}
|
|
}
|
|
};
|
|
|