|
|
@@ -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);
|
|
|
}}
|
|
|
- }});
|
|
|
+ }}
|
|
|
}}
|
|
|
|
|
|
// 获取节点颜色(全局版本,根据节点数据判断维度)
|