增加渲染节点功能,优化工具操作和样式

This commit is contained in:
2026-05-18 15:44:36 +08:00
parent 03ca56d2a7
commit 45274955c6
7 changed files with 278 additions and 97 deletions
+32 -3
View File
@@ -1,4 +1,4 @@
import React, { useState, useEffect, useCallback } from "react";
import React, { useState, useEffect, useCallback, useRef } from "react";
import { useData, useMap } from "../MapComponent";
import ToolbarButton from "@/components/olmap/common/ToolbarButton";
import InfoOutlinedIcon from "@mui/icons-material/InfoOutlined";
@@ -24,6 +24,7 @@ import StyleLegend from "./StyleLegend"; // 引入图例组件
import { handleMapClickSelectFeatures as mapClickSelectFeatures, queryFeaturesByIds } from "@/utils/mapQueryService";
import { useNotification } from "@refinedev/core";
import { useChatToolActionHandler } from "@/hooks/useChatToolActionHandler";
import { applyJunctionAreaRender } from "@components/olmap/DMALeakDetection/applyJunctionAreaRender";
import { config } from "@/config/config";
import { apiFetch } from "@/lib/apiFetch";
@@ -81,8 +82,16 @@ const Toolbar: React.FC<ToolbarProps> = ({
startTime?: string;
endTime?: string;
} | null>(null);
const chatJunctionRenderCleanupRef = useRef<(() => void) | null>(null);
// Wire up chat tool actions (locate, view_history, view_scada)
const disposeChatJunctionRender = useCallback(() => {
chatJunctionRenderCleanupRef.current?.();
chatJunctionRenderCleanupRef.current = null;
}, []);
useEffect(() => () => disposeChatJunctionRender(), [disposeChatJunctionRender]);
// Wire up chat tool actions (locate, view_history, view_scada, render_junctions)
useChatToolActionHandler(
useCallback(
(action) => {
@@ -161,9 +170,29 @@ const Toolbar: React.FC<ToolbarProps> = ({
});
break;
}
case "render_junctions": {
disposeChatJunctionRender();
if (Object.keys(action.nodeAreaMap).length === 0) {
break;
}
if (map) {
chatJunctionRenderCleanupRef.current = applyJunctionAreaRender(
map,
{
nodeAreaMap: action.nodeAreaMap,
areaIds: action.areaIds,
areaColors: action.areaColors,
},
{ propertyKey: "chat_junction_render_index" },
);
}
break;
}
}
},
[map],
[disposeChatJunctionRender, map],
),
);