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/player.js | 2 +- zy-acs-flow/src/map/MapPage.jsx | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 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); diff --git a/zy-acs-flow/src/map/player.js b/zy-acs-flow/src/map/player.js index 3e33579..afc1904 100644 --- a/zy-acs-flow/src/map/player.js +++ b/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; -- Gitblit v1.9.1