瀏覽代碼

修复连线的bug

yemeishu 1 月之前
父節點
當前提交
26ccaab57c
共有 1 個文件被更改,包括 9 次插入1 次删除
  1. 9 1
      resources/views/public/knowledge-mindmap.blade.php

+ 9 - 1
resources/views/public/knowledge-mindmap.blade.php

@@ -478,6 +478,11 @@
                 this.graph.on('node:mouseleave', handleLeave);
                 this.graph.on('edge:mouseenter', handleEdgeEnter);
                 this.graph.on('edge:mouseleave', handleLeave);
+                
+                // 监听布局变化,重新绘制关联线
+                this.graph.on('afterlayout', () => {
+                    this.drawRelationEdges();
+                });
                 // 全量刷新,避免缩放重影
                 const canvas = this.graph && typeof this.graph.get === 'function' ? this.graph.get('canvas') : null;
                 if (canvas && typeof canvas.set === 'function') {
@@ -566,10 +571,13 @@
                     this.relationEdges.forEach((edge, index) => {
                         // 检查节点是否存在
                         if (!this.graph.findById(edge.source) || !this.graph.findById(edge.target)) {
-                            // console.warn(`Edge skipped: ${edge.source} -> ${edge.target} (node missing)`);
                             return;
                         }
                         const model = buildModel(edge, index);
+                        // 防止重复添加
+                        if (this.graph.findById(model.id)) {
+                            return;
+                        }
                         if (canAddEdge) {
                             this.graph.addEdge(model);
                         } else {