#
luxiaotao1123
2024-02-29 c7aa9cc76f90cf4c7510c59e1eff90f762cf400d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import * as React from 'react'
import * as PIXI from 'pixi.js';
import './index.css'
import {
    PageContainer,
} from '@ant-design/pro-components';
// import { FormattedMessage, useIntl, useModel } from '@umijs/max';
 
const Map = () => {
    // const { initialState, setInitialState } = useModel('@@initialState');
    // console.log(initialState);
    const mapRef = React.useRef();
    const [app, setApp] = React.useState(() => {
        return new PIXI.Application({
            background: '#f5f6fa',
            antialias: true,
        })
    })
 
    React.useEffect(() => {
 
        // resize
        const onResize = () => {
            if (mapRef) {
                const width = mapRef.current.offsetWidth;
                const height = window.innerHeight - 92;
                app.renderer.resize(width, height);
            }
        }
        window.addEventListener('resize', onResize);
        onResize();
 
        // app init
        app.stage.interactive = true;
        app.stage.hitArea = app.screen;
        globalThis.__PIXI_APP__ = app;
        mapRef.current.appendChild(app.view);
 
    }, []);
 
    return (
        <>
            <PageContainer
                header={{
                    title: false,
                    subTitle: false,
                    breadcrumb: {},
                }}
                style={{ height: '100%', padding: 0 }} // Here
 
            >
                <div
                    style={{ width: '100%', height: '100%' }}
                    ref={mapRef}
                >
                </div>
            </PageContainer>
        </>
    )
}
 
export default Map;