#
luxiaotao1123
2024-10-10 eaa43a7ce551a02d06c1c77461008759034d0658
zy-acs-flow/src/map/MapPage.jsx
@@ -28,10 +28,10 @@
let player;
const Map = () => {
    const theme = useTheme();
    const themeMode = theme.palette.mode;
    const notify = useNotification();
    const translate = useTranslate();
    const theme = useTheme();
    const themeMode = theme.palette.mode;
    const mapRef = useRef();
    const contentRef = useRef();
@@ -39,8 +39,11 @@
    const [mapContainer, setMapContainer] = useState(null);
    const [mode, setMode] = useState(MapMode.OBSERVER_MODE);
    const [deviceVisible, setDeviceVisible] = React.useState(false);
    const [deviceVisible, setDeviceVisible] = useState(false);
    const [settingsVisible, setSettingsVisible] = useState(false);
    const [spriteSettings, setSpriteSettings] = useState(null);
    const prevSpriteSettingsRef = React.useRef();
    useEffect(() => {
        Tool.patchRaLayout('0px');
@@ -50,6 +53,7 @@
            setMapContainer(player.mapContainer);
            Tool.setApp(player.app);
            Tool.setMapContainer(player.mapContainer);
            Tool.setThemeMode(themeMode);
            Http.setNotify(notify);
            await Http.fetchMapData(0);
@@ -63,10 +67,6 @@
            const height = contentRef.current.offsetHeight;
            player.resize(width, height);
            if (mode === MapMode.MOVABLE_MODE) {
                console.log('aa');
                player.showGridLines();
            }
        };
        handleResize();
        window.addEventListener('resize', handleResize);
@@ -107,6 +107,10 @@
                player.activateMapMultiSelect((selectedSprites, restartFn) => {
                    console.log(selectedSprites);
                });
                mapContainer.children.forEach(child => {
                    Tool.beSettings(child, setSpriteSettings);
                })
                break
            default:
                break
@@ -118,11 +122,9 @@
            return
        }
        switchMode(mode);
    }, [mode]);
    }, [mode, mapContainer]);
    const onDrop = (sprite, type, x, y) => {
        console.log(sprite, type, x, y);
        const { mapX, mapY } = Tool.getRealPosition(x, y);
        sprite.x = mapX;
        sprite.y = mapY;
@@ -132,6 +134,26 @@
        Tool.beMovable(sprite);
    };
    // watch spriteSettings
    useEffect(() => {
        if (!mapContainer) {
            return;
        }
        console.log(spriteSettings);
        prevSpriteSettingsRef.current = spriteSettings;
        if (spriteSettings && prevSpriteSettings !== spriteSettings) {
            Tool.removeSelectedEffect();
        }
        if (spriteSettings) {
            Tool.showSelectedEffect(spriteSettings)
            setSettingsVisible(true);
        } else {
            Tool.removeSelectedEffect();
        }
    }, [spriteSettings, mapContainer])
    const prevSpriteSettings = prevSpriteSettingsRef.current;
    const actions = [
        { icon: <FileCopyIcon />, name: '复制' },
        { icon: <SaveIcon />, name: '保存' },