fix(property): - 添加 websocket 连接状态检查
This commit is contained in:
@@ -8,6 +8,9 @@ import { getWebSocketService } from '#/api/websocket';
|
|||||||
import { currentReading } from '#/api/property/energyManagement/meterInfo';
|
import { currentReading } from '#/api/property/energyManagement/meterInfo';
|
||||||
|
|
||||||
const ws = getWebSocketService();
|
const ws = getWebSocketService();
|
||||||
|
const readingData = ref<any>({});
|
||||||
|
const readingTime = ref('');
|
||||||
|
let readingLoading = ref(false);
|
||||||
|
|
||||||
if (ws) {
|
if (ws) {
|
||||||
// 使用setOnMessageCallback方法设置消息回调
|
// 使用setOnMessageCallback方法设置消息回调
|
||||||
@@ -34,15 +37,15 @@ if (ws) {
|
|||||||
currentReading({ meterType: 0, floorId: 0 });
|
currentReading({ meterType: 0, floorId: 0 });
|
||||||
readingLoading.value = false;
|
readingLoading.value = false;
|
||||||
});
|
});
|
||||||
|
}else {
|
||||||
|
readingLoading.value = false;
|
||||||
|
message.warn('websocket未连接!请刷新页面重试!');
|
||||||
}
|
}
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
|
// 关闭页面,发送请求停止心跳
|
||||||
currentReading({ meterType: 0, floorId: 0 });
|
currentReading({ meterType: 0, floorId: 0 });
|
||||||
});
|
});
|
||||||
|
|
||||||
const readingData = ref<any>({});
|
|
||||||
const readingTime = ref('');
|
|
||||||
let readingLoading = ref(false);
|
|
||||||
async function handleSelectFloor(selectedKeys, info) {
|
async function handleSelectFloor(selectedKeys, info) {
|
||||||
if (typeof selectedKeys[0] === 'undefined') {
|
if (typeof selectedKeys[0] === 'undefined') {
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user