#
luxiaotao1123
2024-11-16 bb3b18aa4627e24e3428f89c90b867bad5eb40f6
zy-acs-flow/src/map/MapPage.jsx
@@ -23,6 +23,7 @@
import MapSearch from "./header/MapSearch";
import { startupOrShutdown } from "./http";
import PulseSignal from "../page/components/PulseSignal";
import FakeFab from "./header/FakeFab";
let player;
let websocket;
@@ -39,7 +40,7 @@
    const [app, setApp] = useState(null);
    const [mapContainer, setMapContainer] = useState(null);
    const [mode, setMode] = useState(null);
    const [mode, setMode] = useState(MAP_MODE.OBSERVER_MODE);
    const [dataFetched, setDataFetched] = useState(false);
    const [insightVisible, setInsightVisible] = useState(false);
    const [deviceVisible, setDeviceVisible] = useState(false);
@@ -47,7 +48,6 @@
    const [batchSelectionVisible, setBatchSelectionVisible] = useState(false);
    const [curSprite, setCurSprite] = useState(null);
    const prevCurSpriteRef = useRef();
    const [batchSprites, setBatchSprites] = useState([]);
    const [rcsStatus, setRcsStatus] = useState(null);
@@ -77,17 +77,17 @@
            Http.setMapContainer(player.mapContainer);
            websocket = new WebSocketClient('/ws/map/websocket');
            await Http.fetchMapData(curZone, setRcsStatus);
            await Http.fetchMapData(curZone, setRcsStatus, setCurSprite);
            websocket.connect();
            websocket.onMessage = (wsMsg) => {
                Tool.generateDynamicGraphic(curZone, JSON.parse(wsMsg), setCurSprite);
            }
            player.rotateMap(localStorage.getItem('mapRotation'));
            setTimeout(() => {
                notify.info(translate('page.map.welcome'));
                player.adaptScreen();
                setDataFetched(true);
                setMode(MAP_MODE.OBSERVER_MODE);
            }, 200)
        }
        initialize();
@@ -189,10 +189,7 @@
        if (!mapContainer) {
            return;
        }
        prevCurSpriteRef.current = curSprite;
        if (curSprite && prevCurSprite !== curSprite) {
            Tool.removeSelectedEffect();
        }
        Tool.removeSelectedEffect();
        if (curSprite) {
            if (mode === MAP_MODE.OBSERVER_MODE) {
                Tool.showSelectedEffect(curSprite);
@@ -208,7 +205,6 @@
            setSettingsVisible(false);
        }
    }, [curSprite]);
    const prevCurSprite = prevCurSpriteRef.current;
    // watch batchSprites
    React.useEffect(() => {
@@ -405,26 +401,27 @@
                    }}
                >
                    {mode !== MAP_MODE.MOVABLE_MODE && (
                        <Fab
                            variant="extended"
                            color={showRoutes ? 'primary' : 'default'}
                            size="small"
                            onClick={() => {
                                showRoutes ? Tool.hideRoutes(curZone, setShowRoutes) : Tool.showRoutes(curZone, setShowRoutes)
                            }}
                        >
                            <AltRoute />
                        </Fab>
                        <>
                            <Fab
                                variant="extended"
                                color={showRoutes ? 'primary' : 'default'}
                                size="small"
                                onClick={() => {
                                    showRoutes ? Tool.hideRoutes(curZone, setShowRoutes) : Tool.showRoutes(curZone, setShowRoutes)
                                }}
                            >
                                <AltRoute />
                            </Fab>
                            <FakeFab
                            />
                        </>
                    )}
                    <Fab
                        variant="extended"
                        color="primary"
                        size="small"
                        onClick={() => {
                            player.rotateMap();
                            // setTimeout(() => {
                            //     player.adaptScreen();
                            // }, 500)
                            player.rotateMap(Math.PI / 2);
                        }}
                    >
                        <RotateRight />