#
luxiaotao1123
2024-03-02 0773d66c559f2d648b62ed8f7db80c7ffc47ce1c
#
1个文件已修改
1个文件已添加
41 ■■■■ 已修改文件
zy-asrs-flow/src/pages/map/index.jsx 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-flow/src/pages/map/utils.js 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-flow/src/pages/map/index.jsx
@@ -6,6 +6,7 @@
import './index.css'
import { createStyles } from 'antd-style';
import Edit from './components/edit'
import * as Utils from './utils'
const useStyles = createStyles(({ token }) => {
    let dark = token.colorBgBase === '#000';
@@ -59,6 +60,10 @@
    });
    React.useEffect(() => {
        Utils.syncApp(app);
        Utils.syncMapContainer(mapContainer);
        const handleResize = () => {
            setWindowSize({
                width: window.innerWidth,
@@ -104,10 +109,9 @@
    }
    const onDrop = (sprite, x, y) => {
        const rect = app.view.getBoundingClientRect();
        sprite.anchor.set(0.5);
        sprite.x = x - rect.left;
        sprite.y = y - rect.top;
        const { mapX, mapY } = Utils.getRealPosition(x, y);
        sprite.x = mapX;
        sprite.y = mapY;
        mapContainer.addChild(sprite);
    }
@@ -126,11 +130,9 @@
            <Edit
                open={editModalVisible}
                onCancel={
                    () => {
                        setEditModalVisible(false);
                    }
                }
                onCancel={() => {
                    setEditModalVisible(false);
                }}
                refCurr={mapRef.current}
                onDrop={onDrop}
                mapContainer={mapContainer}
zy-asrs-flow/src/pages/map/utils.js
New file
@@ -0,0 +1,21 @@
let app = null;
let mapContainer = null;
export function syncApp(param) {
    app = param;
}
export function syncMapContainer(param) {
    mapContainer = param;
}
export const getRealPosition = (x, y) => {
    const rect = app.view.getBoundingClientRect();
    return {
        mapX: x - rect.left,
        mapY: y - rect.top
    }
}