#
luxiaotao1123
2024-10-09 ec5a22c126ea778b8baea29a078dabb05184b65a
zy-acs-flow/src/map/MapPage.jsx
@@ -21,20 +21,23 @@
import Player from './player';
import * as Tool from './tool';
import { NotificationProvider, useNotification } from './Notification';
import Device from "./Device";
let player;
const Map = () => {
    const theme = useTheme();
    const themeMode = theme.palette.mode;
    const notify = useNotification();
    const mapRef = useRef();
    const contentRef = useRef();
    const [app, setApp] = useState(null);
    const [mapContainer, setMapContainer] = useState(null);
    const notify = useNotification();
    const [mode, setMode] = useState(MapMode.OBSERVER_MODE);
    const [deviceVisible, setDeviceVisible] = React.useState(false);
    const theme = useTheme();
    const themeMode = theme.palette.mode;
    useEffect(() => {
        Tool.patchRaLayout('0px');
@@ -90,6 +93,16 @@
        switchMode(mode);
    }, [mode]);
    const onDrop = (sprite, type, x, y) => {
        const { mapX, mapY } = Tool.getRealPosition(x, y);
        sprite.x = mapX;
        sprite.y = mapY;
        // Utils.initSprite(sprite, type);
        // mapContainer.addChild(sprite);
        // Utils.beMovable(sprite);
    };
    const actions = [
        { icon: <FileCopyIcon />, name: '复制' },
        { icon: <SaveIcon />, name: '保存' },
@@ -128,6 +141,39 @@
                    }}
                />
                <Box sx={{ flexGrow: 1 }} />
                {mode === MapMode.OBSERVER_MODE && (
                    <>
                        <Button
                            variant="contained"
                            color="primary"
                            sx={{ mr: 1 }}
                        >
                            停止RCS运转
                        </Button>
                        <Button variant="contained" color="secondary">
                            模拟AGV运行
                        </Button>
                    </>
                )}
                {mode === MapMode.MOVABLE_MODE && (
                    <>
                        <Button
                            variant="contained"
                            color="primary"
                            sx={{ mr: 1 }}
                        >
                            添加模型
                        </Button>
                    </>
                )}
                {mode === MapMode.SETTINGS_MODE && (
                    <>
                    </>
                )}
                <Select
                    value={mode}
                    onChange={(event) => {
@@ -136,7 +182,7 @@
                    variant="outlined"
                    size="small"
                    sx={{
                        mr: 2,
                        ml: 2,
                        backgroundColor: '#fff',
                        borderRadius: 1,
                    }}
@@ -145,16 +191,6 @@
                    <MenuItem value={MapMode.MOVABLE_MODE}>编辑模式</MenuItem>
                    <MenuItem value={MapMode.SETTINGS_MODE}>配置模式</MenuItem>
                </Select>
                <Button
                    variant="contained"
                    color="primary"
                    sx={{ mr: 1 }}
                >
                    停止RCS运转
                </Button>
                <Button variant="contained" color="secondary">
                    模拟AGV运行
                </Button>
            </Box>
            <Box
                sx={{
@@ -196,6 +232,13 @@
                    ))}
                </SpeedDial>
            </Box>
            <Device
                open={deviceVisible}
                onCancel={() => {
                    setDeviceVisible(false);
                }}
                onDrop={onDrop}
            />
        </Box>
    );
}