Преглед изворни кода

feat: 右边匹配列表点击复用左边边的点击效果

- highlightMatchEdge函数现在调用highlightEdge复用完整逻辑
- 包括边高亮、节点高亮、右边树联动、人设树联动
- 显示边详情面板

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
yangxiaohui пре 4 дана
родитељ
комит
a31146bfcf
1 измењених фајлова са 26 додато и 17 уклоњено
  1. 26 17
      script/data_processing/visualize_match_graph.py

+ 26 - 17
script/data_processing/visualize_match_graph.py

@@ -4072,28 +4072,37 @@ HTML_TEMPLATE = '''<!DOCTYPE html>
             }});
         }}
 
-        // 高亮匹配边
+        // 高亮匹配边(复用highlightEdge逻辑)
         function highlightMatchEdge(srcId, tgtId) {{
-            if (!g) return;
-
-            // 重置所有
-            g.selectAll(".node").classed("dimmed", true).classed("highlighted", false);
-            g.selectAll(".link-group").classed("dimmed", true).classed("highlighted", false);
-
-            // 高亮对应的边和节点
-            g.selectAll(".link-group").each(function(d) {{
-                const dSrc = typeof d.source === "object" ? d.source.id : d.source;
-                const dTgt = typeof d.target === "object" ? d.target.id : d.target;
-                if ((dSrc === srcId && dTgt === tgtId) || (dSrc === tgtId && dTgt === srcId)) {{
-                    d3.select(this).classed("dimmed", false).classed("highlighted", true);
+            if (!links) return;
+
+            // 找到对应的边和索引
+            let targetLink = null;
+            let targetIndex = -1;
+            links.forEach((link, i) => {{
+                const lSrc = typeof link.source === "object" ? link.source.id : link.source;
+                const lTgt = typeof link.target === "object" ? link.target.id : link.target;
+                if ((lSrc === srcId && lTgt === tgtId) || (lSrc === tgtId && lTgt === srcId)) {{
+                    targetLink = link;
+                    targetIndex = i;
                 }}
             }});
 
-            g.selectAll(".node").each(function(d) {{
-                if (d.id === srcId || d.id === tgtId) {{
-                    d3.select(this).classed("dimmed", false).classed("highlighted", true);
+            if (targetLink && targetIndex >= 0) {{
+                // 复用highlightEdge的完整逻辑
+                highlightEdge(targetLink, targetIndex);
+                // 显示边详情
+                showEdgeInfo(targetLink);
+                // 联动人设树和关系图
+                const pathNodes = [];
+                const srcNode = typeof targetLink.source === "object" ? targetLink.source.id : targetLink.source;
+                const tgtNode = typeof targetLink.target === "object" ? targetLink.target.id : targetLink.target;
+                if (!srcNode.startsWith("帖子_")) pathNodes.push(srcNode);
+                if (!tgtNode.startsWith("帖子_")) pathNodes.push(tgtNode);
+                if (pathNodes.length > 0) {{
+                    syncTreeAndRelationGraph(pathNodes, targetLink.type);
                 }}
-            }});
+            }}
         }}
 
         // 获取节点颜色(全局版本,根据节点数据判断维度)