#
luxiaotao1123
2024-10-08 c438854e1da8d7025ee85e23dd37c2523c488725
zy-acs-flow/src/map/MapPage.jsx
@@ -23,12 +23,15 @@
const MapPage = () => {
    const mapRef = useRef();
    const contentRef = useRef();
    const [app, setApp] = useState(null);
    const [mapContainer, setMapContainer] = React.useState(null);
    const [windowSize, setWindowSize] = useState({
        width: window.innerWidth,
        height: window.innerHeight,
    });
    const [mode, setMode] = useState('monitoring');
    useEffect(() => {
@@ -44,26 +47,23 @@
                });
            };
            window.addEventListener('resize', handleResize);
        }
        initialize();
        return () => {
            player.app.destroy(true, { children: true });
            window.removeEventListener('resize', () => { });
        };
    }, [])
    // resize
    React.useEffect(() => {
        if (!app) {
            return;
    useEffect(() => {
        if (app && contentRef.current) {
            const width = contentRef.current.offsetWidth;
            const height = contentRef.current.offsetHeight;
            app.renderer.resize(width, height);  // 动态调整 PIXI 大小
        }
        console.log(1);
        const width = contentRef.current.offsetWidth;
        const height = contentRef.current.offsetHeight;
        app.renderer.resize(width, height);
    }, [app, mapContainer, windowSize])
    }, [app, mapContainer]);
    const handleModeChange = (event) => {
        setMode(event.target.value);