From db0554663e0a63bd0d718ae87b381481c663aab2 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期二, 08 十月 2024 13:52:31 +0800
Subject: [PATCH] #
---
zy-acs-flow/src/map/player.js | 14 ++++++-
zy-acs-flow/src/map/MapPage.jsx | 49 +++++++++++++++++++-----
2 files changed, 50 insertions(+), 13 deletions(-)
diff --git a/zy-acs-flow/src/map/MapPage.jsx b/zy-acs-flow/src/map/MapPage.jsx
index 9a4367b..1638915 100644
--- a/zy-acs-flow/src/map/MapPage.jsx
+++ b/zy-acs-flow/src/map/MapPage.jsx
@@ -23,7 +23,6 @@
const MapPage = () => {
const mapRef = useRef();
- const contentRef = useRef();
const [app, setApp] = useState(null);
const [mapContainer, setMapContainer] = React.useState(null);
@@ -34,17 +33,46 @@
const themeMode = theme.palette.mode;
useEffect(() => {
- const initialize = async () => {
- player = new Player(mapRef.current, themeMode);
- setApp(player.app);
- setMapContainer(player.mapContainer);
+ const parentElement = document.getElementById('main-content');
+ if (parentElement && parentElement.classList.contains('RaLayout-content')) {
+ parentElement.style.paddingLeft = '0px';
+ parentElement.style.paddingRight = '0px';
}
- initialize();
+
+ // const initialize = async () => {
+ // player = new Player(mapRef.current, themeMode);
+ // setApp(player.app);
+ // setMapContainer(player.mapContainer);
+
+
+
+ // }
+ // initialize();
+
+ // // resize
+ // const handleResize = () => {
+ // player.resize();
+ // };
+ // window.addEventListener('resize', handleResize);
+ // handleResize();
+
+
+ // return () => {
+ // player.destroy();
+ // window.removeEventListener('resize', handleResize);
+ // };
return () => {
- player.app.destroy(true, { children: true });
+ // 閿�姣� Pixi.js 搴旂敤
+ // ...
+
+ // 鎭㈠鐖跺鍣ㄧ殑鍐呰竟璺�
+ if (parentElement && parentElement.classList.contains('RaLayout-content')) {
+ parentElement.style.paddingLeft = '';
+ parentElement.style.paddingRight = '';
+ }
};
- }, [])
+ }, [themeMode])
const handleModeChange = (event) => {
setMode(event.target.value);
@@ -61,7 +89,6 @@
return (
<Box
sx={{
- margin: '0 -8px',
height: '100%',
display: 'flex',
flexDirection: 'column',
@@ -120,17 +147,17 @@
flexGrow: 1, // fill remaining of map space
position: 'relative',
backgroundColor: '#fff',
+
}}
>
<Box
- ref={contentRef}
+ ref={mapRef}
sx={{
width: '100%',
height: '100%',
backgroundColor: '#e0e0e0',
}}
>
- <div ref={mapRef} />
</Box>
<SpeedDial
diff --git a/zy-acs-flow/src/map/player.js b/zy-acs-flow/src/map/player.js
index e418eba..0bc4bd9 100644
--- a/zy-acs-flow/src/map/player.js
+++ b/zy-acs-flow/src/map/player.js
@@ -6,7 +6,7 @@
constructor(dom, themeMode) {
this.themeMode = themeMode;
- this.app = generateApp(themeMode);
+ this.app = generateApp(dom, themeMode);
dom.appendChild(this.app.view);
globalThis.__PIXI_APP__ = this.app;
@@ -23,12 +23,22 @@
});
}
+ resize() {
+ // 濡傛灉闇�瑕佸湪绐楀彛澶у皬鏀瑰彉鏃惰皟鏁村唴瀹癸紝鍙互鍦ㄨ繖閲屽鐞�
+ // 鐢变簬璁剧疆浜� resizeTo锛孭IXI.Application 浼氳嚜鍔ㄨ皟鏁寸敾甯冨昂瀵�
+ }
+
+ destroy() {
+ this.app.destroy(true, { children: true });
+ }
+
}
-const generateApp = (themeMode) => {
+const generateApp = (dom, themeMode) => {
const app = new PIXI.Application({
background: themeMode === 'dark' ? '#2f3542' : '#f1f2f6',
antialias: true,
+ resizeTo: dom,
})
app.stage.eventMode = 'static';
app.stage.hitArea = app.screen;
--
Gitblit v1.9.1