#
Junjie
2024-04-07 0254b3caa25819d038754baa58b03824303b5fa7
zy-asrs-flow/src/pages/map/index.jsx
@@ -8,13 +8,13 @@
    FileAddOutlined,
    CompressOutlined,
    SettingOutlined,
    CloseOutlined
} from '@ant-design/icons';
import './index.css'
import { createStyles } from 'antd-style';
import Edit from './components/device';
import Settings from './components/settings'
import * as Utils from './utils'
import WebSocketClient from './websocket'
import Player from './player';
import MapSearch from './header/search';
import MapFloor from './header/floor';
@@ -60,7 +60,7 @@
    SETTINGS_MODEL: "3",
})
let player;
let player, websocket;
const Map = () => {
    const intl = useIntl();
@@ -85,11 +85,10 @@
    const [dataFetched, setDataFetched] = React.useState(false);
    const [curSprite, setCurSPrite] = React.useState(null);
    const prevCurSpriteRef = React.useRef();
    const hasFloor = true;
    // const [hasFloor, setHasFloor] = React.useState(true);
    const [floorList, setFloorList] = React.useState([]);
    const [curFloor, setCurFloor] = React.useState(() => {
        const storedValue = localStorage.getItem('curFloor');
        return storedValue !== null ? JSON.parse(storedValue) : 1;
        return storedValue !== null ? JSON.parse(storedValue) : null;
    });
    const [batchSprites, setBatchSprites] = React.useState([]);
    const [batchDrawerVisible, setBatchDrawerVisible] = React.useState(false);
@@ -104,6 +103,10 @@
            Utils.syncMapContainer(player.mapContainer);
            Utils.syncNotify(notify);
            websocket = new WebSocketClient('/ws/map/websocket');
            websocket.connect();
            websocket.onMessage = Utils.updateMapStatusInRealTime;
            const handleResize = () => {
                setWindowSize({
                    width: window.innerWidth,
@@ -112,7 +115,11 @@
            };
            window.addEventListener('resize', handleResize);
            await Utils.fetchMapData(curFloor);
            const mapFloorData = await Utils.fetchMapFloor();
            setFloorList(mapFloorData);
            let defaultFloor = curFloor || mapFloorData?.[0]?.value;
            setCurFloor(defaultFloor);
            await Utils.fetchMapData(defaultFloor);
            setDataFetched(true);
            setModel(MapModel.OBSERVER_MODEL)
            setTimeout(() => {
@@ -368,8 +375,9 @@
                <Content ref={contentRef} className={styles.content}>
                    <div ref={mapRef} />
                    {hasFloor && (
                    {floorList.length > 0 && (
                        <MapFloor
                            floorList={floorList}
                            curFloor={curFloor}
                            setCurFloor={setCurFloor}
                        />
@@ -428,6 +436,7 @@
            <MapDrawer
                open={drawerVisible}
                curSprite={curSprite}
                curFloor={curFloor}
                refCurr={mapRef.current}
                onCancel={() => {
                    setCurSPrite(null);