Ver código fonte

fix: 匹配列表去重,避免双向边重复显示

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

Co-Authored-By: Claude <noreply@anthropic.com>
yangxiaohui 23 horas atrás
pai
commit
aa625ddbde

+ 8 - 1
script/visualization/src/components/PostTreeView.vue

@@ -229,14 +229,21 @@ function copyJson() {
 // 当前选中的帖子索引
 const selectedPostIdx = ref(store.selectedPostIndex)
 
-// 匹配边列表(按分数从高到低排序,无分数的放最后)
+// 匹配边列表(按分数从高到低排序,去重,无分数的放最后)
 const sortedMatchEdges = computed(() => {
   const postGraph = store.currentPostGraph
   if (!postGraph?.edges) return []
 
   const matchEdges = []
+  const seen = new Set()  // 用于去重
+
   for (const [edgeId, edge] of Object.entries(postGraph.edges)) {
     if (edge.type === '匹配') {
+      // 生成去重key(两个节点排序后拼接,确保A-B和B-A生成相同的key)
+      const pairKey = [edge.source, edge.target].sort().join('|')
+      if (seen.has(pairKey)) continue
+      seen.add(pairKey)
+
       // 获取源节点和目标节点名称
       const sourceNode = postGraph.nodes?.[edge.source]
       const targetNode = store.getNode(edge.target)  // 目标是人设节点