From b3cd0b749e427c5c8e4dba8e9f01c6cff51d07d7 Mon Sep 17 00:00:00 2001
From: vincentlu <t1341870251@gmail.com>
Date: 星期一, 19 一月 2026 12:47:44 +0800
Subject: [PATCH] #

---
 zy-acs-flow/src/map/MapPage.jsx |   29 +++++++++++++++++++++--------
 1 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/zy-acs-flow/src/map/MapPage.jsx b/zy-acs-flow/src/map/MapPage.jsx
index a28cf21..8b229e2 100644
--- a/zy-acs-flow/src/map/MapPage.jsx
+++ b/zy-acs-flow/src/map/MapPage.jsx
@@ -8,7 +8,7 @@
     useTheme,
     Fab,
 } from '@mui/material';
-import { MAP_MODE, MAP_DEFAULT_ROTATION } from "./constants";
+import { MAP_MODE, MAP_DEFAULT_ROTATION, setMapPreferences } from "./constants";
 import Player from './player';
 import * as Tool from './tool';
 import { NotificationProvider, useNotification } from './Notification';
@@ -68,7 +68,9 @@
     });
 
     const handleResize = () => {
-        if (!contentRef) { return; }
+        if (!contentRef.current || !player) {
+            return;
+        }
         const width = contentRef.current.offsetWidth;
         const height = contentRef.current.offsetHeight;
         player.resize(width, height);
@@ -85,6 +87,7 @@
             Tool.setThemeMode(themeMode);
             Http.setNotify(notify);
             Http.setMapContainer(player.mapContainer);
+            await Http.fetchMapPreferences(curZone, setMapPreferences);
             websocket = new WebSocketClient('/ws/map/websocket');
 
             await Http.fetchMapData(curZone, setRcsStatus, setCurSprite);
@@ -124,6 +127,9 @@
     }, [sidebarOpen]);
 
     useEffect(() => {
+        if (!player) {
+            return;
+        }
         player.setTheme(themeMode);
         Tool.setThemeMode(themeMode);
     }, [themeMode])
@@ -218,6 +224,7 @@
         if (!mapContainer) {
             return;
         }
+        setAreaListVisible(false);
         Tool.removeSelectedEffect();
         if (curSprite) {
             if (mode === MAP_MODE.OBSERVER_MODE) {
@@ -375,11 +382,14 @@
                             {translate('page.map.action.areaList')}
                         </Button>
                         <Button
-                            variant={areaDrawing ? "outlined" : "contained"}
-                            color="primary"
-                            sx={{}}
-                            disabled={areaDrawing}
+                            variant="contained"
+                            color={areaDrawing ? "error" : "primary"}
                             onClick={() => {
+                                if (areaDrawing) {
+                                    Tool.cancelAreaDrawing();
+                                    setAreaDrawing(false);
+                                    return;
+                                }
                                 setCurSprite(null);
                                 const started = Tool.startAreaDrawing({
                                     promptText: translate('page.map.area.prompt.nameInput'),
@@ -402,7 +412,9 @@
                                 }
                             }}
                         >
-                            {translate('page.map.action.addArea')}
+                            {areaDrawing
+                                ? translate('page.map.action.cancelAddArea')
+                                : translate('page.map.action.addArea')}
                         </Button>
                     </>
                 )}
@@ -576,7 +588,8 @@
                 zoneId={curZone}
                 open={areaListVisible}
                 onClose={() => setAreaListVisible(false)}
-                width={400}
+                setCurSprite={setCurSprite}
+                width={378}
             />
 
         </Box>

--
Gitblit v1.9.1