1
This commit is contained in:
41
app/store/modules/system.js
Normal file
41
app/store/modules/system.js
Normal file
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* 系统信息状态管理
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user