From 5510c0c383a06ebca91e6813d4b54ef0772af306 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期一, 08 四月 2024 13:30:00 +0800
Subject: [PATCH] #

---
 zy-asrs-flow/src/pages/map/index.jsx |    8 ++++++--
 zy-asrs-flow/src/pages/map/utils.js  |    4 +++-
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/zy-asrs-flow/src/pages/map/index.jsx b/zy-asrs-flow/src/pages/map/index.jsx
index a1c3cb2..d2a22fa 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,7 +106,9 @@
 
             websocket = new WebSocketClient('/ws/map/websocket');
             websocket.connect();
-            websocket.onMessage = Utils.updateMapStatusInRealTime;
+            websocket.onMessage = (data) => {
+                Utils.updateMapStatusInRealTime(data, () => curFloorRef.current);
+            }
 
             const handleResize = () => {
                 setWindowSize({
@@ -252,6 +255,7 @@
 
     // watch curFloor
     React.useEffect(() => {
+        curFloorRef.current = curFloor;
         if (!mapContainer && !dataFetched) {
             return;
         }
diff --git a/zy-asrs-flow/src/pages/map/utils.js b/zy-asrs-flow/src/pages/map/utils.js
index cd651d7..07585aa 100644
--- a/zy-asrs-flow/src/pages/map/utils.js
+++ b/zy-asrs-flow/src/pages/map/utils.js
@@ -613,7 +613,9 @@
     return row + '-' + bay + '-' + lev;
 }
 
-export const updateMapStatusInRealTime = (data) => {
+export const updateMapStatusInRealTime = (data, curFloorGetter) => {
+    const curFloor = curFloorGetter();
+    if (isNullOfUndefined(curFloor)) { return; }
     const mapVo = JSON.parse(data);
     // shuttle
     for (const shuttleVo of mapVo.shuttleVos) {

--
Gitblit v1.9.1