| | |
| | | |
| | | const Map = () => { |
| | | const mapRef = useRef(); |
| | | const contentRef = React.useRef(); |
| | | const contentRef = useRef(); |
| | | const [app, setApp] = useState(null); |
| | | const [mapContainer, setMapContainer] = React.useState(null); |
| | | const [mapContainer, setMapContainer] = useState(null); |
| | | const notify = useNotification(); |
| | | |
| | | const [mode, setMode] = useState(MapModel.OBSERVER_MODEL); |
| | | const [mode, setMode] = useState(MapMode.OBSERVER_MODE); |
| | | |
| | | const theme = useTheme(); |
| | | const themeMode = theme.palette.mode; |
| | |
| | | }; |
| | | }, [themeMode]) |
| | | |
| | | const switchMode = (mode) => { |
| | | switch (mode) { |
| | | case MapMode.OBSERVER_MODE: |
| | | console.log('a'); |
| | | break |
| | | case MapMode.MOVABLE_MODE: |
| | | console.log('b'); |
| | | break |
| | | case MapMode.SETTINGS_MODE: |
| | | console.log('c'); |
| | | break |
| | | default: |
| | | break |
| | | } |
| | | } |
| | | |
| | | const handleModeChange = (event) => { |
| | | setMode(event.target.value); |
| | | }; |
| | | useEffect(() => { |
| | | if (!mapContainer) { |
| | | return |
| | | } |
| | | switchMode(mode); |
| | | }, [mode]); |
| | | |
| | | const actions = [ |
| | | { icon: <FileCopyIcon />, name: '复制' }, |
| | |
| | | <Box sx={{ flexGrow: 1 }} /> |
| | | <Select |
| | | value={mode} |
| | | onChange={handleModeChange} |
| | | onChange={(event) => { |
| | | setMode(event.target.value); |
| | | }} |
| | | variant="outlined" |
| | | size="small" |
| | | sx={{ |
| | |
| | | borderRadius: 1, |
| | | }} |
| | | > |
| | | <MenuItem value={MapModel.OBSERVER_MODEL}>监控模式</MenuItem> |
| | | <MenuItem value={MapModel.MOVABLE_MODEL}>编辑模式</MenuItem> |
| | | <MenuItem value={MapModel.SETTINGS_MODEL}>配置模式</MenuItem> |
| | | <MenuItem value={MapMode.OBSERVER_MODE}>监控模式</MenuItem> |
| | | <MenuItem value={MapMode.MOVABLE_MODE}>编辑模式</MenuItem> |
| | | <MenuItem value={MapMode.SETTINGS_MODE}>配置模式</MenuItem> |
| | | </Select> |
| | | <Button |
| | | variant="contained" |
| | |
| | | ) |
| | | } |
| | | |
| | | export const MapModel = Object.freeze({ |
| | | OBSERVER_MODEL: "1", |
| | | MOVABLE_MODEL: "2", |
| | | SETTINGS_MODEL: "3", |
| | | export const MapMode = Object.freeze({ |
| | | OBSERVER_MODE: "1", |
| | | MOVABLE_MODE: "2", |
| | | SETTINGS_MODE: "3", |
| | | }) |
| | | |
| | | export default MapPage; |