From c438854e1da8d7025ee85e23dd37c2523c488725 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期二, 08 十月 2024 13:17:34 +0800 Subject: [PATCH] # --- zy-acs-flow/src/map/MapPage.jsx | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-) diff --git a/zy-acs-flow/src/map/MapPage.jsx b/zy-acs-flow/src/map/MapPage.jsx index 6005182..155c827 100644 --- a/zy-acs-flow/src/map/MapPage.jsx +++ b/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); -- Gitblit v1.9.1