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;