From 27cf960ce17de1ac1152a39ba0e51c8054c3db3c Mon Sep 17 00:00:00 2001 From: zcxlsm Date: Wed, 3 Sep 2025 15:14:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(property):=20-=20=E6=B7=BB=E5=8A=A0=20webso?= =?UTF-8?q?cket=20=E8=BF=9E=E6=8E=A5=E7=8A=B6=E6=80=81=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../electricEnergy/elctricitySituation/index.vue | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/web-antd/src/views/property/energyManagement/electricEnergy/elctricitySituation/index.vue b/apps/web-antd/src/views/property/energyManagement/electricEnergy/elctricitySituation/index.vue index 4b6b1c7d..e5642255 100644 --- a/apps/web-antd/src/views/property/energyManagement/electricEnergy/elctricitySituation/index.vue +++ b/apps/web-antd/src/views/property/energyManagement/electricEnergy/elctricitySituation/index.vue @@ -8,6 +8,9 @@ import { getWebSocketService } from '#/api/websocket'; import { currentReading } from '#/api/property/energyManagement/meterInfo'; const ws = getWebSocketService(); +const readingData = ref({}); +const readingTime = ref(''); +let readingLoading = ref(false); if (ws) { // 使用setOnMessageCallback方法设置消息回调 @@ -34,15 +37,15 @@ if (ws) { currentReading({ meterType: 0, floorId: 0 }); readingLoading.value = false; }); +}else { + readingLoading.value = false; + message.warn('websocket未连接!请刷新页面重试!'); } onBeforeUnmount(() => { + // 关闭页面,发送请求停止心跳 currentReading({ meterType: 0, floorId: 0 }); }); - -const readingData = ref({}); -const readingTime = ref(''); -let readingLoading = ref(false); async function handleSelectFloor(selectedKeys, info) { if (typeof selectedKeys[0] === 'undefined') { return;