From 728ad81fa10d2879654c5f9ae4314db94eafb865 Mon Sep 17 00:00:00 2001 From: Junjie <540245094@qq.com> Date: 星期五, 01 八月 2025 08:08:18 +0800 Subject: [PATCH] # --- src/main/webapp/views/console.html | 25 ++++++++++++++++++------- 1 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/main/webapp/views/console.html b/src/main/webapp/views/console.html index 93c1aa3..538a39d 100644 --- a/src/main/webapp/views/console.html +++ b/src/main/webapp/views/console.html @@ -358,17 +358,13 @@ }, methods: { init() { - this.ws = new WebSocket("ws://" + window.location.host + baseUrl + "/console/websocket"); - this.ws.onopen = this.webSocketOnOpen - this.ws.onerror = this.webSocketOnError - this.ws.onmessage = this.webSocketOnMessage - this.ws.onclose = this.webSocketClose - this.getMap(this.currentLev) this.getSystemRunningStatus() //鑾峰彇绯荤粺杩愯鐘舵�� this.initLev()//鍒濆鍖栨ゼ灞備俊鎭� this.consoleInterval = setInterval(() => { + this.websocketConnect() + this.getShuttleStateInfo() //鑾峰彇鍥涘悜绌挎杞︿俊鎭� this.getLiftStateInfo() //鑾峰彇鎻愬崌鏈轰俊鎭� this.getSiteInfo() //鑾峰彇杈撻�佺珯鐐规暟鎹� @@ -709,10 +705,20 @@ } } }, + websocketConnect() { + if (this.ws == null) { + this.ws = new WebSocket("ws://" + window.location.host + baseUrl + "/console/websocket"); + this.ws.onopen = this.webSocketOnOpen + this.ws.onerror = this.webSocketOnError + this.ws.onmessage = this.webSocketOnMessage + this.ws.onclose = this.webSocketClose + } + }, webSocketOnOpen(e) { console.log("open"); }, webSocketOnError(e) { + this.ws = null; console.log(e); }, webSocketOnMessage(e) { @@ -730,11 +736,16 @@ } }, webSocketClose(e) { + this.ws = null; console.log("close"); }, sendWs(message) { + if (this.ws == null) { + return; + } + if (this.ws.readyState == WebSocket.OPEN) { - this.ws.send(message) + this.ws.send(message); } } } -- Gitblit v1.9.1