| | |
| | | 'map.edit': 'Edit Model', |
| | | 'map.edit.close': 'Exit Edit', |
| | | 'map.device.add': 'Add New Device', |
| | | '': '', |
| | | 'map.device.oper': 'Param Settings', |
| | | '': '', |
| | | '': '', |
| | | '': '', |
| | |
| | | AppstoreAddOutlined, |
| | | FileAddOutlined, |
| | | CompressOutlined, |
| | | SettingOutlined, |
| | | } from '@ant-design/icons'; |
| | | import './index.css' |
| | | import { createStyles } from 'antd-style'; |
| | |
| | | const [app, setApp] = React.useState(null); |
| | | const [mapContainer, setMapContainer] = React.useState(null); |
| | | const [mapEditModel, setMapEditModel] = React.useState(false); |
| | | const [deviceSettingModel, setDeviceSettingModel] = React.useState(false); |
| | | |
| | | // init func |
| | | React.useEffect(() => { |
| | | player = new Player(mapRef.current, styles.dark); |
| | | setApp(player.app); |
| | |
| | | window.addEventListener('resize', handleResize); |
| | | }, []); |
| | | |
| | | // resize |
| | | React.useEffect(() => { |
| | | if (!app) { |
| | | return; |
| | |
| | | app.renderer.resize(width, height); |
| | | }, [app, mapContainer, windowSize]) |
| | | |
| | | // Edit Model |
| | | React.useEffect(() => { |
| | | if (!mapContainer) { |
| | | return; |
| | | } |
| | | if (mapEditModel) { |
| | | player.showGridlines(); |
| | | mapContainer.children.forEach(child => { |
| | | Utils.beMovable(child); |
| | | }) |
| | | } else { |
| | | player.hideGridlines(); |
| | | mapContainer.children.forEach(child => { |
| | | child.off('pointerup'); |
| | | child.off('pointerdown'); |
| | | child.off('click'); |
| | | }) |
| | | } |
| | | }, [mapEditModel]); |
| | | |
| | | // Settings Model |
| | | React.useEffect(() => { |
| | | if (!mapContainer) { |
| | | return; |
| | | } |
| | | if (deviceSettingModel) { |
| | | |
| | | } else { |
| | | |
| | | } |
| | | }, [deviceSettingModel]); |
| | | |
| | | // Add New Device |
| | | const onDrop = (sprite, x, y) => { |
| | | const { mapX, mapY } = Utils.getRealPosition(x, y, mapContainer); |
| | | sprite.x = mapX; |
| | |
| | | setDeviceVisible(true); |
| | | }} |
| | | /> |
| | | <FloatButton |
| | | tooltip={<div><FormattedMessage id='map.device.oper' defaultMessage='参数设置' /></div>} |
| | | icon={<SettingOutlined />} |
| | | onClick={() => { |
| | | setDeviceSettingModel(true); |
| | | }} |
| | | /> |
| | | </FloatButton.Group> |
| | | </Content> |
| | | </Layout> |