From cc91a835ff9fbf3e9e33ac5a9ea51432f9f3bf24 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期四, 10 十月 2024 16:11:01 +0800 Subject: [PATCH] # --- zy-acs-flow/src/map/MapPage.jsx | 43 +++++++++++++++++++++++++++++++++++++++---- 1 files changed, 39 insertions(+), 4 deletions(-) diff --git a/zy-acs-flow/src/map/MapPage.jsx b/zy-acs-flow/src/map/MapPage.jsx index a2335b3..283b0e0 100644 --- a/zy-acs-flow/src/map/MapPage.jsx +++ b/zy-acs-flow/src/map/MapPage.jsx @@ -22,10 +22,14 @@ import Player from './player'; import * as Tool from './tool'; import { NotificationProvider, useNotification } from './Notification'; +import Insight from "./insight"; import Device from "./Device"; +import Settings from "./settings"; import * as Http from './http'; +import WebSocketClient from './websocket' let player; +let websocket; const Map = () => { const notify = useNotification(); @@ -39,6 +43,7 @@ const [mapContainer, setMapContainer] = useState(null); const [mode, setMode] = useState(MapMode.OBSERVER_MODE); + const [insightVisible, setInsightVisible] = useState(false); const [deviceVisible, setDeviceVisible] = useState(false); const [settingsVisible, setSettingsVisible] = useState(false); @@ -55,8 +60,13 @@ Tool.setMapContainer(player.mapContainer); Tool.setThemeMode(themeMode); Http.setNotify(notify); + // websocket = new WebSocketClient('/ws/map/websocket'); await Http.fetchMapData(0); + // websocket.connect(); + // websocket.onMessage = (data) => { + // Tool.updateMapStatusInRealTime(data, () => curFloorRef.current, setCurSPrite); + // } } initialize(); @@ -74,6 +84,10 @@ notify('Welcome to Rcs', 'info'); return () => { + if (websocket) { + websocket.onMessage = () => { } + websocket.close(); + } player.destroy(); window.removeEventListener('resize', handleResize); Tool.patchRaLayout(''); @@ -81,9 +95,15 @@ }, [themeMode]) const switchMode = (mode) => { + Tool.removeSelectedEffect(); + + setDeviceVisible(false); + setSettingsVisible(false); + + setSpriteSettings(null); + switch (mode) { case MapMode.OBSERVER_MODE: - setDeviceVisible(false); player.hideGridLines(); player.activateMapMultiSelect((selectedSprites, restartFn) => { @@ -102,7 +122,6 @@ break case MapMode.SETTINGS_MODE: player.hideGridLines(); - setDeviceVisible(false); player.activateMapMultiSelect((selectedSprites, restartFn) => { console.log(selectedSprites); @@ -139,8 +158,6 @@ if (!mapContainer) { return; } - console.log(spriteSettings); - prevSpriteSettingsRef.current = spriteSettings; if (spriteSettings && prevSpriteSettings !== spriteSettings) { Tool.removeSelectedEffect(); @@ -288,6 +305,14 @@ </SpeedDial> </Box> + <Insight + open={insightVisible} + onCancel={() => { + setInsightVisible(false); + }} + width={378} + /> + <Device open={deviceVisible} onCancel={() => { @@ -297,6 +322,16 @@ width={378} /> + <Settings + open={settingsVisible} + onCancel={() => { + setSpriteSettings(null); + setSettingsVisible(false); + }} + sprite={spriteSettings} + width={570} + /> + </Box> ); } -- Gitblit v1.9.1