From bb61bc0c22ae4ef9963ca00d23b5cf0c412f26f5 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期六, 12 十月 2024 14:47:35 +0800 Subject: [PATCH] # --- zy-acs-flow/src/map/MapPage.jsx | 53 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 49 insertions(+), 4 deletions(-) diff --git a/zy-acs-flow/src/map/MapPage.jsx b/zy-acs-flow/src/map/MapPage.jsx index a0688d7..f99eaf5 100644 --- a/zy-acs-flow/src/map/MapPage.jsx +++ b/zy-acs-flow/src/map/MapPage.jsx @@ -27,6 +27,7 @@ import Settings from "./settings"; import * as Http from './http'; import WebSocketClient from './websocket' +import ConfirmButton from "../page/components/ConfirmButton"; let player; let websocket; @@ -48,7 +49,12 @@ const [settingsVisible, setSettingsVisible] = useState(false); const [spriteSettings, setSpriteSettings] = useState(null); - const prevSpriteSettingsRef = React.useRef(); + const prevSpriteSettingsRef = useRef(); + + const [curZone, setCurZone] = useState(() => { + const storedValue = localStorage.getItem('curZone'); + return storedValue !== null ? JSON.parse(storedValue) : null; + }); useEffect(() => { Tool.patchRaLayout('0px'); @@ -60,9 +66,10 @@ Tool.setMapContainer(player.mapContainer); Tool.setThemeMode(themeMode); Http.setNotify(notify); + Http.setMapContainer(player.mapContainer); // websocket = new WebSocketClient('/ws/map/websocket'); - await Http.fetchMapData(0); + await Http.fetchMapData(); // websocket.connect(); // websocket.onMessage = (data) => { // Tool.updateMapStatusInRealTime(data, () => curFloorRef.current, setCurSPrite); @@ -81,7 +88,7 @@ handleResize(); window.addEventListener('resize', handleResize); - notify('Welcome to Rcs', 'info'); + notify.info('Welcome to Rcs'); return () => { if (websocket) { @@ -92,6 +99,11 @@ window.removeEventListener('resize', handleResize); Tool.patchRaLayout(''); }; + }, []) + + useEffect(() => { + player.setTheme(themeMode); + Tool.setThemeMode(themeMode); }, [themeMode]) const switchMode = (mode) => { @@ -200,7 +212,7 @@ padding: '0 16px', height: '64px', flexShrink: 0, // keep height - zIndex: 200 + zIndex: 200, }} > <TextField @@ -233,6 +245,23 @@ {mode === MapMode.MOVABLE_MODE && ( <> <Button + variant="outlined" + sx={{ mr: 2 }} + onClick={() => { + Tool.clearMapData(); + }} + > + {translate('page.map.action.clear')} + </Button> + <ConfirmButton + label="page.map.action.save" + variant="contained" + sx={{ mr: 2 }} + onConfirm={() => { + Http.saveMapData(curZone); + }} + /> + <Button variant="contained" color="primary" sx={{ mr: 1 }} @@ -245,6 +274,22 @@ {mode === MapMode.SETTINGS_MODE && ( <> + <Button + variant="outlined" + sx={{ mr: 2 }} + onClick={() => { + Tool.clearMapData(); + }} + > + {translate('page.map.action.clear')} + </Button> + <ConfirmButton + label="page.map.action.save" + variant="contained" + onConfirm={() => { + Http.saveMapData(curZone); + }} + /> </> )} -- Gitblit v1.9.1