Browse Source

所有的上报信息存储到日志

master
王梦远 2 weeks ago
parent
commit
58c567e1a8
  1. 8
      src/components/system/ErrorEventsModal.vue
  2. 32
      src/layouts/default.vue
  3. 16
      src/stores/systemStore.ts

8
src/components/system/ErrorEventsModal.vue

@ -2,13 +2,13 @@
import { ref, watchEffect } from 'vue' import { ref, watchEffect } from 'vue'
import { syncSendCmd } from '@/apis/system' import { syncSendCmd } from '@/apis/system'
// import { useDeviceStore } from '@/stores/deviceStore'
import { useDeviceStore } from '@/stores/deviceStore'
// const deviceStore = useDeviceStore()
const deviceStore = useDeviceStore()
const appEvents = ref<Record<string, any>[]>([]) const appEvents = ref<Record<string, any>[]>([])
watchEffect(() => { watchEffect(() => {
// appEvents.value = deviceStore.deviceStete.appEvents
appEvents.value = deviceStore.deviceStete.appEvents
}) })
const confirmClose = (item: Record<string, any>) => { const confirmClose = (item: Record<string, any>) => {
@ -41,7 +41,7 @@ const confirmClose = (item: Record<string, any>) => {
{{ checkItem.ecodeInfo }} {{ checkItem.ecodeInfo }}
</span> </span>
</span> </span>
<!-- <span v-else>{{ item.description || item.message }}</span> -->
<span v-else>{{ item.description || item.message }}</span>
<div class="actions"> <div class="actions">
<button class="delete-button" @click.stop="confirmClose(item)"> <button class="delete-button" @click.stop="confirmClose(item)">
关闭 关闭

32
src/layouts/default.vue

@ -151,7 +151,7 @@ const toggleLanguage = () => {
const statusMap = { const statusMap = {
info: { info: {
type: 'primary', type: 'primary',
name: '设备提示信息',
name: '设备弹窗信息',
}, },
success: { success: {
type: 'success', type: 'success',
@ -234,20 +234,6 @@ const statusMap = {
</router-view> </router-view>
</el-main> </el-main>
</el-container> </el-container>
<!-- <footer class="footer">
<div class="ip-info">
IP : {{ deviceInfo.ip }}
</div>
<div class="alarm-info">
<img :src="HomeAlarmSvg" width="20" alt="报警">
<div class="alarm-workState">
{{ workStateName || '空闲' }}
</div>
</div>
<div class="time">
{{ currentTime }}
</div>
</footer> -->
<el-footer class="footer"> <el-footer class="footer">
<el-row> <el-row>
<el-col :span="6"> <el-col :span="6">
@ -279,8 +265,8 @@ const statusMap = {
> >
<div style="display: flex; justify-content: space-between; width: 100%"> <div style="display: flex; justify-content: space-between; width: 100%">
<span> <span>
<span>{{ item.name }}: </span>
<span>{{ statusMap[item.status as keyof typeof statusMap].name }}</span>
<span>{{ statusMap[item.status as keyof typeof statusMap].name }}: </span>
<span>{{ item.name }}</span>
</span> </span>
<span>{{ item.time }}</span> <span>{{ item.time }}</span>
</div> </div>
@ -392,6 +378,18 @@ const statusMap = {
background: #fff; background: #fff;
} }
} }
.log-box {
width: 500px;
height: 400px;
overflow: auto;
:deep(.el-tag) {
margin: 5px 0;
width: 100%;
.el-tag__content {
width: 100%;
}
}
}
.aside { .aside {
overflow: hidden; overflow: hidden;
padding-left: 10px; padding-left: 10px;

16
src/stores/systemStore.ts

@ -15,23 +15,29 @@ export const useSystemStore = defineStore('system', () => {
systemLogList.value.unshift(log) systemLogList.value.unshift(log)
systemLogList.value = systemLogList.value.slice(0, 200) systemLogList.value = systemLogList.value.slice(0, 200)
} }
const uuids: Set<string> = new Set()
const insertLogs = (appEvents: System.appEvent[]) => { const insertLogs = (appEvents: System.appEvent[]) => {
appEvents.forEach((item) => { appEvents.forEach((item) => {
if (item.type === 'AppCheckPointCheckFailEvent' && item.errCheckPoints) {
if (uuids.has(item.uuid)) {
return
}
if (uuids.size > 500) {
uuids.clear()
}
uuids.add(item.uuid)
if (item.type === 'AppCheckPointCheckFailEvent' && item.errCheckPoints) { // 传感器检测失败弹窗事件
item.errCheckPoints.forEach((errCheckPoint) => { 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 } 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) insertLog(log)
}) })
} }
if (item.type === 'AppWarningPromoptEvent') {
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 } 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) ElMessage.warning(item.description)
insertLog(log) insertLog(log)
} }
if (item.type === 'AppPromoptEvent') {
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 } 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) insertLog(log)
} }
}) })

Loading…
Cancel
Save