#
vincentlu
2025-12-17 25abc0ce6236550a9a91ac3897a46fe07f688a96
#
2个文件已修改
67 ■■■■■ 已修改文件
zy-acs-flow/src/map/AreaList.jsx 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-flow/src/map/tool.js 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-acs-flow/src/map/AreaList.jsx
@@ -15,6 +15,7 @@
import CloseIcon from '@mui/icons-material/Close';
import { PAGE_DRAWER_WIDTH } from '@/config/setting';
import { fetchAreaList } from './http';
import * as Tool from './tool';
const AreaList = ({
    open,
@@ -37,14 +38,20 @@
        setLoading(true);
        fetchAreaList(zoneId)
            .then((list) => {
                console.log(list);
                setAreas(Array.isArray(list) ? list : []);
            })
            .finally(() => setLoading(false));
    }, [open, zoneId]);
    const handleItemClick = (area) => {
        if (!area?.id) {
            return;
        }
        const sprite = Tool.findAreaSpriteById(area.id);
        if (sprite) {
            Tool.focusAreaSprite(sprite);
            // Tool.showSelectedEffect?.(sprite);
        }
        onSelect?.(area);
    };
zy-acs-flow/src/map/tool.js
@@ -399,6 +399,20 @@
        .start();
}
export const findAreaSpriteById = (areaId) => {
    if (!mapContainer || areaId == null) {
        return null;
    }
    const targetId = String(areaId);
    for (let i = 0; i < mapContainer.children.length; i += 1) {
        const child = mapContainer.children[i];
        if (child?.data?.type === DEVICE_TYPE.AREA && String(child.data?.id) === targetId) {
            return child;
        }
    }
    return null;
};
export const clearMapData = () => {
    if (!mapContainer) {
        return;
@@ -1144,3 +1158,45 @@
    clearAreas();
    setShowAreas(false);
};
export const focusAreaSprite = (sprite) => {
    if (!sprite || !app || !mapContainer) {
        return;
    }
    const data = sprite.data || {};
    const start = data.start;
    const end = data.end;
    const currentScale = Math.abs(mapContainer.scale.x || 1);
    const boundsBefore = sprite.getBounds();
    const width = start && end ? Math.abs(end.x - start.x) : boundsBefore.width / currentScale;
    const height = start && end ? Math.abs(end.y - start.y) : boundsBefore.height / currentScale;
    const paddedWidth = (width || 1000) * 1.25;
    const paddedHeight = (height || 1000) * 1.25;
    const viewportWidth = app.renderer.width || 1920;
    const viewportHeight = app.renderer.height || 1080;
    let focusScale = Math.min(
        (viewportWidth * 0.65) / paddedWidth,
        (viewportHeight * 0.65) / paddedHeight
    );
    focusScale = Math.min(Math.max(focusScale, 0.03), 0.25);
    mapContainer.scale.set(MAP_MIRROR ? -focusScale : focusScale, focusScale);
    mapContainer.position.set(0, 0);
    const bounds = sprite.getBounds();
    const centerX = bounds.x + bounds.width / 2;
    const centerY = bounds.y + bounds.height / 2;
    const targetPos = {
        x: viewportWidth / 2 - centerX,
        y: viewportHeight / 2 - centerY,
    };
    new TWEEDLE.Tween(mapContainer.position)
        .easing(TWEEDLE.Easing.Quadratic.Out)
        .to(targetPos, 500)
        .start();
};