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

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
@@ -136,6 +136,26 @@ const resolveTimeRange = (params: Record<string, unknown>) => ({
(params.end as string | undefined),
});
const resolveStringRecord = (value: unknown): Record<string, string> => {
if (!value || typeof value !== "object" || Array.isArray(value)) {
return {};
}
return Object.fromEntries(
Object.entries(value as Record<string, unknown>)
.map(([key, recordValue]) => [String(key), String(recordValue ?? "")])
.filter(([, recordValue]) => recordValue.trim().length > 0),
);
};
const resolveStringArray = (value: unknown): string[] => {
if (!Array.isArray(value)) {
return [];
}
return value.map((item) => String(item).trim()).filter(Boolean);
};
const compactNames = (names: string[]) => {
if (!names.length) return "";
return names.length > 3
@@ -230,6 +250,24 @@ const buildToolAction = (
};
}
if (tool === "render_junctions") {
const nodeAreaMap = resolveStringRecord(params.node_area_map);
const areaIds = resolveStringArray(params.area_ids);
const areaColors = resolveStringRecord(params.area_colors);
return {
action: {
type: "render_junctions",
nodeAreaMap,
areaIds,
areaColors,
},
kind: "map",
title: "渲染节点分区",
description: `${Object.keys(nodeAreaMap).length} 个节点`,
};
}
return {
action: null,
kind: "tool",