From 7df10afba7d61de89c30e1c447a260b9a50ecf35 Mon Sep 17 00:00:00 2001 From: Wenjie Zhang Date: Sat, 20 Dec 2025 15:53:27 +0800 Subject: [PATCH] =?UTF-8?q?refactor(ui):=20=E4=BC=98=E5=8C=96=E7=9F=A5?= =?UTF-8?q?=E8=AF=86=E5=9B=BE=E8=B0=B1=E7=95=8C=E9=9D=A2=E5=B8=83=E5=B1=80?= =?UTF-8?q?=E5=92=8C=E4=BA=A4=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 调整图谱布局参数提升渲染效果 重构顶部操作栏布局,改进搜索框样式和交互 移除冗余的说明按钮 --- web/src/components/GraphCanvas.vue | 12 +-- web/src/components/KnowledgeGraphSection.vue | 107 ++++++++++++++----- web/src/views/GraphView.vue | 3 - 3 files changed, 84 insertions(+), 38 deletions(-) diff --git a/web/src/components/GraphCanvas.vue b/web/src/components/GraphCanvas.vue index cf74fdad..ea08de65 100644 --- a/web/src/components/GraphCanvas.vue +++ b/web/src/components/GraphCanvas.vue @@ -68,14 +68,13 @@ const MAX_RETRIES = 5 const defaultLayout = { type: 'd3-force', preventOverlap: true, - // 性能友好参数(参考 GraphView.vue) alphaDecay: 0.1, alphaMin: 0.01, - velocityDecay: 0.7, - iterations: 100, + velocityDecay: 0.6, + iterations: 150, force: { center: { x: 0.5, y: 0.5, strength: 0.1 }, - charge: { strength: -400, distanceMax: 400 }, + charge: { strength: -400, distanceMax: 600 }, link: { distance: 100, strength: 0.8 }, }, collide: { radius: 40, strength: 0.8, iterations: 3 }, @@ -217,9 +216,6 @@ function initGraph() { const { target } = evt // 获取节点ID const nodeId = target.id - // 从 graph data 中找到对应的节点数据 - // 注意:G6 v5 的事件对象结构可能有所不同,这里假设 target.id 是节点ID - // 也可以通过 graphInstance.getNodeData(nodeId) 获取 const nodeData = graphInstance.getNodeData(nodeId) emit('node-click', nodeData) }) @@ -271,7 +267,7 @@ function setGraphData() { emit('data-rendered') console.log('图谱渲染完成,布局已稳定') }, 1500) - }, 10) // 等待 1ms 确保布局完成 + }, 10) // 等待 10ms 确保布局完成 } // 关键词高亮功能 diff --git a/web/src/components/KnowledgeGraphSection.vue b/web/src/components/KnowledgeGraphSection.vue index 3255e225..e27980c2 100644 --- a/web/src/components/KnowledgeGraphSection.vue +++ b/web/src/components/KnowledgeGraphSection.vue @@ -18,26 +18,34 @@ > @@ -94,7 +102,7 @@