|
|
@ -1,3 +1,5 @@ |
|
|
|
import { ElMessage } from 'element-plus' |
|
|
|
import { formatDateTime } from 'libs/utils' |
|
|
|
import { defineStore } from 'pinia' |
|
|
|
import { ref } from 'vue' |
|
|
|
|
|
|
@ -8,7 +10,32 @@ export const useSystemStore = defineStore('system', () => { |
|
|
|
const systemUser = ref({ |
|
|
|
username: '', |
|
|
|
}) |
|
|
|
|
|
|
|
const systemLogList = ref<System.SystemLog[]>([]) |
|
|
|
const insertLog = (log: System.SystemLog) => { |
|
|
|
systemLogList.value.unshift(log) |
|
|
|
systemLogList.value = systemLogList.value.slice(0, 200) |
|
|
|
} |
|
|
|
const insertLogs = (appEvents: System.appEvent[]) => { |
|
|
|
appEvents.forEach((item) => { |
|
|
|
if (item.type === 'AppCheckPointCheckFailEvent' && item.errCheckPoints) { |
|
|
|
item.errCheckPoints.forEach((errCheckPoint) => { |
|
|
|
const log: System.SystemLog = { name: `${errCheckPoint.ecodeInfo}(${errCheckPoint.ecode})`, status: 'check', time: formatDateTime('YYYY-MM-DD HH:mm:ss', Date.now()), uuid: item.uuid } |
|
|
|
ElMessage.error(errCheckPoint.ecodeInfo) |
|
|
|
insertLog(log) |
|
|
|
}) |
|
|
|
} |
|
|
|
if (item.type === 'AppWarningPromoptEvent') { |
|
|
|
const log: System.SystemLog = { name: item.description || '', status: 'warn', time: formatDateTime('YYYY-MM-DD HH:mm:ss', Date.now()), uuid: item.uuid } |
|
|
|
ElMessage.warning(item.description) |
|
|
|
insertLog(log) |
|
|
|
} |
|
|
|
if (item.type === 'AppPromoptEvent') { |
|
|
|
const log: System.SystemLog = { name: item.message || '', status: 'info', time: formatDateTime('YYYY-MM-DD HH:mm:ss', Date.now()), uuid: item.uuid } |
|
|
|
ElMessage.warning(item.message) |
|
|
|
insertLog(log) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
const loginForm = ref({ |
|
|
|
name: import.meta.env.FT_NODE_ENV !== 'prod' ? 'admin' : '', |
|
|
|
pwd: import.meta.env.FT_NODE_ENV !== 'prod' ? '9973' : '', |
|
|
@ -102,9 +129,11 @@ export const useSystemStore = defineStore('system', () => { |
|
|
|
loading, |
|
|
|
websocketConnected, |
|
|
|
systemTime, |
|
|
|
|
|
|
|
systemLogList, |
|
|
|
updateLoading, |
|
|
|
updateConnected, |
|
|
|
getSystemTime, |
|
|
|
insertLog, |
|
|
|
insertLogs, |
|
|
|
} |
|
|
|
}) |