From 0d04bc5d8080b82338302fba0a59fccff2eaedfc Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期日, 06 七月 2025 11:28:29 +0800
Subject: [PATCH] #

---
 zy-asrs-flow/src/pages/device/lift/index.jsx |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/zy-asrs-flow/src/pages/device/lift/index.jsx b/zy-asrs-flow/src/pages/device/lift/index.jsx
index ebe0a9c..8d80fb7 100644
--- a/zy-asrs-flow/src/pages/device/lift/index.jsx
+++ b/zy-asrs-flow/src/pages/device/lift/index.jsx
@@ -6,6 +6,7 @@
     PageContainer,
 } from '@ant-design/pro-components';
 import './index.less'
+import { WEBSOCKET_BASE_URL } from '@/config/setting';
 
 const Main = () => {
     const [deviceInfos, setDeviceInfos] = useState([]);
@@ -16,8 +17,7 @@
     const [mapLev, setMapLev] = useState([]);
 
     useEffect(() => {
-        var newWs = new WebSocket("ws://127.0.0.1:9090/wcs/ws/lift/websocket");
-        setWs(newWs);
+        connect();
 
         getMapLev();
 
@@ -55,6 +55,7 @@
 
             ws.onclose = function (e) {
                 console.log("close");
+                reconnect();
             }
 
             ws.onerror = function (e) {
@@ -62,6 +63,18 @@
             }
         }
     }, [ws]);
+    
+    const connect = () => {
+        var newWs = new WebSocket(WEBSOCKET_BASE_URL + "/ws/lift/websocket");
+        setWs(newWs);
+    }
+
+    const reconnect = () => {
+        setTimeout(() => {
+            console.log('WebSocketClient: Attempting to reconnect...');
+            connect();
+        }, 3000);
+    }
 
     const sendWs = (message) => {
         if (ws.readyState == WebSocket.OPEN) {

--
Gitblit v1.9.1