#
luxiaotao1123
2024-10-08 c438854e1da8d7025ee85e23dd37c2523c488725
#
2个文件已修改
20 ■■■■ 已修改文件
zy-acs-flow/src/map/MapPage.jsx 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-flow/src/map/player.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
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;
        }
        console.log(1);
    useEffect(() => {
        if (app && contentRef.current) {
        const width = contentRef.current.offsetWidth;
        const height = contentRef.current.offsetHeight;
        app.renderer.resize(width, height);
    }, [app, mapContainer, windowSize])
            app.renderer.resize(width, height);  // 动态调整 PIXI 大小
        }
    }, [app, mapContainer]);
    const handleModeChange = (event) => {
        setMode(event.target.value);
zy-acs-flow/src/map/player.js
@@ -7,7 +7,7 @@
        this.app = new PIXI.Application({
            background: '#f1f2f6',
            antialias: true,
            // resizeTo: dom, // 自动调整 canvas 尺寸
            resizeTo: dom, // 自动调整 canvas 尺寸
        })
        this.app.stage.eventMode = 'static';
        this.app.stage.hitArea = this.app.screen;