From 0617722410f21916ae96d40d30e0778e2239217d Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期五, 26 四月 2024 12:55:04 +0800
Subject: [PATCH] #

---
 zy-asrs-flow/src/pages/map/index.jsx |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/zy-asrs-flow/src/pages/map/index.jsx b/zy-asrs-flow/src/pages/map/index.jsx
index 2fec0aa..7c039da 100644
--- a/zy-asrs-flow/src/pages/map/index.jsx
+++ b/zy-asrs-flow/src/pages/map/index.jsx
@@ -1,5 +1,5 @@
 import * as React from 'react'
-import * as PIXI from 'pixi.js';
+import * as TWEEDLE from 'tweedle.js';
 import { FormattedMessage, useIntl, useModel } from '@umijs/max';
 import { Layout, Button, Flex, Row, Col, FloatButton, Select, notification, Segmented } from 'antd';
 const { Header, Content } = Layout;
@@ -90,6 +90,7 @@
         const storedValue = localStorage.getItem('curFloor');
         return storedValue !== null ? JSON.parse(storedValue) : null;
     });
+    const curFloorRef = React.useRef(curFloor);
     const [batchSprites, setBatchSprites] = React.useState([]);
     const [batchDrawerVisible, setBatchDrawerVisible] = React.useState(false);
 
@@ -105,6 +106,9 @@
 
             websocket = new WebSocketClient('/ws/map/websocket');
             websocket.connect();
+            websocket.onMessage = (data) => {
+                Utils.updateMapStatusInRealTime(data, () => curFloorRef.current, setCurSPrite);
+            }
 
             const handleResize = () => {
                 setWindowSize({
@@ -127,6 +131,13 @@
             }, 200)
         }
         initialize();
+
+        return () => {
+            websocket.onMessage = (data) => {}
+            if (websocket) {
+                websocket.close();
+            }
+        }
     }, []);
 
     // resize
@@ -251,6 +262,7 @@
 
     // watch curFloor
     React.useEffect(() => {
+        curFloorRef.current = curFloor;
         if (!mapContainer && !dataFetched) {
             return;
         }

--
Gitblit v1.9.1