| | |
| | | import * as React from 'react' |
| | | import * as PIXI from 'pixi.js'; |
| | | import * as TWEEDLE from 'tweedle.js'; |
| | | import { FormattedMessage, useIntl, useModel } from '@umijs/max'; |
| | | import { Layout, Button, Flex, Row, Col, FloatButton, Select, notification, Segmented } from 'antd'; |
| | | const { Header, Content } = Layout; |
| | |
| | | const storedValue = localStorage.getItem('curFloor'); |
| | | return storedValue !== null ? JSON.parse(storedValue) : null; |
| | | }); |
| | | const curFloorRef = React.useRef(curFloor); |
| | | const [batchSprites, setBatchSprites] = React.useState([]); |
| | | const [batchDrawerVisible, setBatchDrawerVisible] = React.useState(false); |
| | | |
| | |
| | | |
| | | websocket = new WebSocketClient('/ws/map/websocket'); |
| | | websocket.connect(); |
| | | |
| | | setInterval(() => { |
| | | websocket.sendMessage('asds') |
| | | }, 1000) |
| | | websocket.onMessage = (data) => { |
| | | Utils.updateMapStatusInRealTime(data, () => curFloorRef.current, setCurSPrite); |
| | | } |
| | | |
| | | const handleResize = () => { |
| | | setWindowSize({ |
| | |
| | | }, 200) |
| | | } |
| | | initialize(); |
| | | console.log(1); |
| | | |
| | | return () => { |
| | | websocket.onMessage = (data) => {} |
| | | if (websocket) { |
| | | websocket.close(); |
| | | } |
| | | } |
| | | }, []); |
| | | |
| | | // resize |
| | |
| | | |
| | | // watch curFloor |
| | | React.useEffect(() => { |
| | | curFloorRef.current = curFloor; |
| | | if (!mapContainer && !dataFetched) { |
| | | return; |
| | | } |