#
luxiaotao1123
2024-10-11 a908604f5aa2da9921cd99c12a6fa422d5893f4a
zy-acs-flow/src/map/MapPage.jsx
@@ -26,8 +26,10 @@
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();
@@ -58,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,9 +81,13 @@
        handleResize();
        window.addEventListener('resize', handleResize);
        notify('Welcome to Rcs', 'info');
        notify.info('Welcome to Rcs');
        return () => {
            if (websocket) {
                websocket.onMessage = () => { }
                websocket.close();
            }
            player.destroy();
            window.removeEventListener('resize', handleResize);
            Tool.patchRaLayout('');
@@ -94,6 +105,7 @@
        switch (mode) {
            case MapMode.OBSERVER_MODE:
                player.hideGridLines();
                player.hideStarryBackground();
                player.activateMapMultiSelect((selectedSprites, restartFn) => {
                    console.log(selectedSprites);
@@ -102,6 +114,7 @@
                break
            case MapMode.MOVABLE_MODE:
                player.showGridLines();
                player.hideStarryBackground();
                player.activateMapMultiSelect((selectedSprites, restartFn) => {
                    Tool.spriteListBeMovable(selectedSprites, () => {
@@ -111,6 +124,7 @@
                break
            case MapMode.SETTINGS_MODE:
                player.hideGridLines();
                player.showStarryBackground(); // 0x2f68ac
                player.activateMapMultiSelect((selectedSprites, restartFn) => {
                    console.log(selectedSprites);
@@ -299,6 +313,7 @@
                onCancel={() => {
                    setInsightVisible(false);
                }}
                width={378}
            />
            <Device
@@ -313,8 +328,12 @@
            <Settings
                open={settingsVisible}
                onCancel={() => {
                    setSpriteSettings(null);
                    setSettingsVisible(false);
                }}
                sprite={spriteSettings}
                setSpriteSettings={setSpriteSettings}
                width={570}
            />
        </Box>