From ed77186749d3627d8df4c8aba7dea16e50f8bcf2 Mon Sep 17 00:00:00 2001 From: suixy <2277317060@qq.com> Date: Thu, 8 Jan 2026 14:57:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/src/App.vue b/src/App.vue index 9f3b428..49c5132 100644 --- a/src/App.vue +++ b/src/App.vue @@ -112,13 +112,22 @@ export default { } return value; }) - console.log('收到全局WebSocket数据:', data) + // console.log('收到全局WebSocket数据:', data) if (data.deviceParam) { // 通过事件总线转发设备数据到需要的组件 this.$bus.$emit('websocket-device-data', data) + } - this.isOnline[data.deviceParam.monitorId] = new Date().getTime() + console.log(data.deviceParam.monitorId) + + if (data.monitorId && data.monitorId.toString().length === 9 && data.monitorId.toString()[0] === '9') { + let str1 = data.monitorId.toString() + let str2 = str1.slice(1) + let startStr = str2.slice(0, 4); + let endStr = str2.slice(4); + let key = 'E' + startStr + '_' + endStr; + this.isOnline[key] = new Date().getTime() this.selectOffLineDevice() } @@ -300,7 +309,7 @@ export default { if (alarmData.deviceParam) { // 温度异常 if (alarmData.deviceParam.temperature && - (alarmData.deviceParam.temperature > 50 || alarmData.deviceParam.temperature < -20)) { + (alarmData.deviceParam.temperature > 50 || alarmData.deviceParam.temperature < -20)) { priority += 10 // 极端温度高优先级 } @@ -369,7 +378,7 @@ export default { }, saveLo(e) { let localStorageData = localStorage.getItem('ERROR') - let data = {} + let data = [] if (localStorageData) { data = JSON.parse(localStorageData) } @@ -378,18 +387,18 @@ export default { }, selectOffLineDevice() { Object.keys(this.isOnline).forEach(key => { - // console.log(key, new Date().getTime() - this.isOnline[key]) - if (new Date().getTime() - this.isOnline[key] > (1000 * 60 * 60)) { - console.log('error', key, parseTime(new Date().getTime())) - this.saveLo(key) - this.$confirm(`设备${key}已离线`, '设备离线', { - cancelButtonText: '关闭', - showConfirmButton: false, - type: 'error' - }) - this.isOnline[key] = new Date().getTime() + // console.log(key, new Date().getTime() - this.isOnline[key]) + if (new Date().getTime() - this.isOnline[key] > (1000 * 60 * 60)) { + console.log('error', key, parseTime(new Date().getTime())) + this.saveLo(key) + this.$confirm(`设备${key}已离线`, '设备离线', { + cancelButtonText: '关闭', + showConfirmButton: false, + type: 'error' + }) + this.isOnline[key] = new Date().getTime() + } } - } ) } }