diff --git a/docs/latest/changelog/roadmap.md b/docs/latest/changelog/roadmap.md index 9add7e57..800398d1 100644 --- a/docs/latest/changelog/roadmap.md +++ b/docs/latest/changelog/roadmap.md @@ -18,6 +18,7 @@ - 目前的知识库的图片存在公开访问风险 - 工具传递给模型的时候,使用英文,显示的时候,使用中文(尽量保持一致) - 首页加载的问题 +- lightrag 类型的图谱的节点数量统计有问题 ### 新增 - 新增对于上传附件的智能体中间件,详见[文档](https://xerrors.github.io/Yuxi-Know/latest/advanced/agents-config.html#%E6%96%87%E4%BB%B6%E4%B8%8A%E4%BC%A0%E4%B8%AD%E9%97%B4%E4%BB%B6) diff --git a/web/src/components/GraphCanvas.vue b/web/src/components/GraphCanvas.vue index 9458be8e..95be6686 100644 --- a/web/src/components/GraphCanvas.vue +++ b/web/src/components/GraphCanvas.vue @@ -142,7 +142,7 @@ function initGraph() { labelFill: getCSSVariable('--gray-700'), labelWordWrap: true, // enable label ellipsis labelMaxWidth: '300%', - size: (d) => { + size: (d) => { if (!props.sizeByDegree) return 24 const deg = d.data.degree || 0 return Math.min(15 + deg * 5, 50) @@ -228,14 +228,33 @@ function setGraphData() { if (!graphInstance) initGraph() if (!graphInstance) return const data = formatData() + + console.log('开始设置图谱数据:', { + nodes: data.nodes.length, + edges: data.edges.length + }) + graphInstance.setData(data) graphInstance.render() - // 应用关键词高亮 + // 手动触发布局重新计算,确保节点分布 setTimeout(() => { - applyHighlightKeywords() - emit('data-rendered') - }, 100) + try { + if (graphInstance && graphInstance.layout) { + graphInstance.layout() + console.log('触发布局重新计算') + } + } catch (error) { + console.warn('布局重新计算失败:', error) + } + + // 等待力导向布局稳定后再应用高亮 + setTimeout(() => { + applyHighlightKeywords() + emit('data-rendered') + console.log('图谱渲染完成,布局已稳定') + }, 1500) + }, 10) // 等待 1ms 确保布局完成 } // 关键词高亮功能