From 4d383881585e94063d1ac3a98b436d07a270755f Mon Sep 17 00:00:00 2001 From: caill <815519168@qq.com> Date: Thu, 4 Jun 2026 10:46:58 +0800 Subject: [PATCH] =?UTF-8?q?websocket=20=E8=BF=9E=E6=8E=A5IP=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/shells/index.vue | 32 +++++++++++++++++++++++---- src/pages/shells/websocket-status.vue | 18 +++++++++++++++ 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/src/pages/shells/index.vue b/src/pages/shells/index.vue index 3687353..a44ed70 100644 --- a/src/pages/shells/index.vue +++ b/src/pages/shells/index.vue @@ -53,6 +53,7 @@ :wsConnected="isConnected" :vehicleConnected="vehicleConnected" :rcsConnected="rcsConnected" + @configModalHandle="configModalHandle" /> @@ -208,8 +209,22 @@ export default { clearTimeout(this.reconnectTimer) this.reconnectTimer = null } + + this.isInitializing = false + this.isConnecting = true + this.isConnected = false + this.vehicleConnected = false + this.rcsConnected = false + + this.topInfo = {} + this.taskSeq = [] + this.currentStep = null + this.closeWebSocket() - this.initWebSocket() + + setTimeout(() => { + this.initWebSocket() + }, 300) }, // 滚动区域 checkTextOverflow () { @@ -247,10 +262,15 @@ export default { this.isInitializing = true this.isConnecting = true - if (this.reconnectTimer) clearTimeout(this.reconnectTimer) + if (this.reconnectTimer) { + clearTimeout(this.reconnectTimer) + this.reconnectTimer = null + } + const wsHost = this.serverUrl.replace(/^https?:\/\//, '') const lang = this.$i18n.locale.slice(0, 2) const wsUrl = `ws://${wsHost}/webSocket/VehicleInfo/${this.userRole}?lang=${lang}` + this.closeWebSocket() try { @@ -319,8 +339,12 @@ export default { }, closeWebSocket () { if (this.websocket) { - this.websocket.onclose = null - this.websocket.close(1000, '正常关闭') + try { + this.websocket.onclose = null + this.websocket.close(1000, 'Switching connection') + } catch (e) { + console.log(e) + } this.websocket = null } }, diff --git a/src/pages/shells/websocket-status.vue b/src/pages/shells/websocket-status.vue index 6ef8784..ac82c43 100644 --- a/src/pages/shells/websocket-status.vue +++ b/src/pages/shells/websocket-status.vue @@ -1,5 +1,8 @@