From 0440a8fa461a4d16b4d6f4d30ee9d7a27c5526f6 Mon Sep 17 00:00:00 2001 From: gtz <535262213@qq.com> Date: Tue, 16 May 2023 15:30:48 +0800 Subject: [PATCH] 'update' --- src/components/boxes/KilnRuntime.vue | 2 +- src/utils/wsClass.js | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/boxes/KilnRuntime.vue b/src/components/boxes/KilnRuntime.vue index 080b61f..843b8ba 100644 --- a/src/components/boxes/KilnRuntime.vue +++ b/src/components/boxes/KilnRuntime.vue @@ -37,7 +37,7 @@ export default { }, methods: { getRuntime() { - const diff = Date.now() - new Date("2023-5-12 10:00:00"); + const diff = Date.now() - new Date("2023-4-21 10:36:00"); const days = parseInt(diff / 1000 / 60 / 60 / 24); const hours = parseInt( (diff - days * 24 * 60 * 60 * 1000) / 1000 / 60 / 60 diff --git a/src/utils/wsClass.js b/src/utils/wsClass.js index 0e536c1..1cc5f27 100644 --- a/src/utils/wsClass.js +++ b/src/utils/wsClass.js @@ -28,8 +28,12 @@ function handleError(err) { console.log('[x] 出错:', err, err.data) } -function handleClose() { +function handleClose(data) { console.log('[x] 服务器关闭连接') + setTimeout(() => { + const wsc = new WsClient(data); + wsc.registerListeners(); + }, 30000) } @@ -77,7 +81,7 @@ export default class WsClient { if (!WsClient.socket.onopen) WsClient.socket.onopen = handleOpen if (!WsClient.socket.onmessage) WsClient.socket.onmessage = handleData.bind(this.vueInstance) if (!WsClient.socket.onerror) WsClient.socket.onerror = handleError - if (!WsClient.socket.onclose) WsClient.socket.onclose = handleClose + if (!WsClient.socket.onclose) WsClient.socket.onclose = handleClose(this.vueInstance) } static createSocket() {