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;
|