|
|
@@ -506,6 +506,9 @@ const FlowChartComponent: ForwardRefRenderFunction<FlowChartRef, FlowChartProps>
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ // Map to store invalid nodes by their anchor parent ID
|
|
|
+ const invalidNodesByAnchor = new Map<string, LayoutNode[]>();
|
|
|
+
|
|
|
invalidBranches.forEach((branch) => {
|
|
|
if (branch.length === 0) return;
|
|
|
const firstMsg = branch[0];
|
|
|
@@ -517,6 +520,7 @@ const FlowChartComponent: ForwardRefRenderFunction<FlowChartRef, FlowChartProps>
|
|
|
if (parentNode) {
|
|
|
let currentParent = parentNode;
|
|
|
const X_OFFSET = -200; // 向左偏移
|
|
|
+ const currentBranchNodes: LayoutNode[] = [];
|
|
|
|
|
|
branch.forEach((msg, idx) => {
|
|
|
const nodeId = `invalid-${msg.id || Math.random()}`;
|
|
|
@@ -531,6 +535,7 @@ const FlowChartComponent: ForwardRefRenderFunction<FlowChartRef, FlowChartProps>
|
|
|
isInvalid: true,
|
|
|
};
|
|
|
nodes.push(node);
|
|
|
+ currentBranchNodes.push(node);
|
|
|
|
|
|
edges.push({
|
|
|
id: `edge-${currentParent.id}-${node.id}`,
|
|
|
@@ -545,6 +550,28 @@ const FlowChartComponent: ForwardRefRenderFunction<FlowChartRef, FlowChartProps>
|
|
|
|
|
|
currentParent = node;
|
|
|
});
|
|
|
+
|
|
|
+ // Store in map
|
|
|
+ if (!invalidNodesByAnchor.has(parentNode.id)) {
|
|
|
+ invalidNodesByAnchor.set(parentNode.id, []);
|
|
|
+ }
|
|
|
+ invalidNodesByAnchor.get(parentNode.id)!.push(...currentBranchNodes);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // Associate invalid nodes with collapsible edges
|
|
|
+ // If a parent node is hidden (part of a collapsed edge), its invalid children should also be hidden
|
|
|
+ edges.forEach((edge) => {
|
|
|
+ if (edge.collapsible && edge.children) {
|
|
|
+ const extraChildren: LayoutNode[] = [];
|
|
|
+ edge.children.forEach((child) => {
|
|
|
+ if (invalidNodesByAnchor.has(child.id)) {
|
|
|
+ extraChildren.push(...invalidNodesByAnchor.get(child.id)!);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (extraChildren.length > 0) {
|
|
|
+ edge.children.push(...extraChildren);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
@@ -899,13 +926,13 @@ const FlowChartComponent: ForwardRefRenderFunction<FlowChartRef, FlowChartProps>
|
|
|
|
|
|
if (sourceIsMessage || targetIsMessage) {
|
|
|
// msgGroup 相关的连接线用灰色
|
|
|
- color = "#9E9E9E";
|
|
|
+ color = "#94a3b8"; // Slate 400
|
|
|
} else if (sourceIsMainGoal && targetIsMainGoal) {
|
|
|
// 主节点之间的连接线用绿色
|
|
|
- color = "#4CAF50";
|
|
|
+ color = "#10b981"; // Emerald 500
|
|
|
} else {
|
|
|
// sub_goals 之间的连接线用蓝色
|
|
|
- color = "#2196F3";
|
|
|
+ color = "#3b82f6"; // Blue 500
|
|
|
}
|
|
|
|
|
|
return (
|
|
|
@@ -913,10 +940,10 @@ const FlowChartComponent: ForwardRefRenderFunction<FlowChartRef, FlowChartProps>
|
|
|
<path
|
|
|
d={path}
|
|
|
fill="none"
|
|
|
- stroke={edge.isInvalid ? "#9E9E9E" : color} // 失效边使用灰色
|
|
|
+ stroke={edge.isInvalid ? "#cbd5e1" : color} // 失效边使用浅灰色 (Slate 300)
|
|
|
strokeWidth={strokeWidth}
|
|
|
strokeDasharray={edge.isInvalid ? "5,5" : undefined} // 失效边使用虚线
|
|
|
- markerEnd="url(#arrow-default)" // 箭头
|
|
|
+ markerEnd={edge.isInvalid ? undefined : "url(#arrow-default)"} // 失效边不显示箭头
|
|
|
style={{ cursor: edge.collapsible ? "pointer" : "default" }} // 可折叠的显示手型光标
|
|
|
onClick={() => edge.collapsible && toggleCollapse(edge.id)} // 点击切换折叠状态
|
|
|
/>
|
|
|
@@ -962,11 +989,15 @@ const FlowChartComponent: ForwardRefRenderFunction<FlowChartRef, FlowChartProps>
|
|
|
const data = node.data as Goal;
|
|
|
const text = isGoal ? data.description : (node.data as Message).description || "";
|
|
|
|
|
|
- let textColor = "#2196F3"; // 默认蓝色
|
|
|
+ let textColor = "#3b82f6"; // Blue 500
|
|
|
if (node.type === "message") {
|
|
|
- textColor = "#9E9E9E"; // 消息节点灰色
|
|
|
+ textColor = "#64748b"; // Slate 500
|
|
|
} else if (node.type === "goal" && node.level === 0) {
|
|
|
- textColor = "#4CAF50"; // 主节点绿色
|
|
|
+ textColor = "#10b981"; // Emerald 500
|
|
|
+ }
|
|
|
+
|
|
|
+ if (node.isInvalid) {
|
|
|
+ textColor = "#94a3b8"; // Slate 400
|
|
|
}
|
|
|
|
|
|
return (
|
|
|
@@ -983,10 +1014,16 @@ const FlowChartComponent: ForwardRefRenderFunction<FlowChartRef, FlowChartProps>
|
|
|
width={150}
|
|
|
height={50}
|
|
|
rx={8}
|
|
|
- fill={isGoal ? "#E3F2FD" : "#F5F5F5"} // 目标节点浅蓝色,消息节点灰色
|
|
|
- stroke={selectedNodeId === node.id ? "#2196F3" : node.isInvalid ? "#9E9E9E" : "#BDBDBD"} // 失效节点边框灰色
|
|
|
+ fill={isGoal ? "#eff6ff" : "#f8fafc"} // Blue 50 / Slate 50
|
|
|
+ stroke={selectedNodeId === node.id ? "#3b82f6" : node.isInvalid ? "#cbd5e1" : "#e2e8f0"} // Selected: Blue 500, Invalid: Slate 300, Default: Slate 200
|
|
|
strokeWidth={selectedNodeId === node.id ? 2 : 1}
|
|
|
strokeDasharray={node.isInvalid ? "5,5" : undefined} // 失效节点虚线边框
|
|
|
+ style={{
|
|
|
+ filter:
|
|
|
+ selectedNodeId === node.id
|
|
|
+ ? "drop-shadow(0 4px 6px rgb(59 130 246 / 0.3))"
|
|
|
+ : "drop-shadow(0 1px 2px rgb(0 0 0 / 0.05))",
|
|
|
+ }}
|
|
|
/>
|
|
|
{/* 节点文本(带 Tooltip) */}
|
|
|
<foreignObject
|