Skip to content

Commit c5dde79

Browse files
committed
refactor(components): 移除独立信息面板组件并整合到GraphCanvas中
将GraphInfoPanel和LightRAGInfoPanel组件删除,将其功能整合到GraphCanvas组件中 简化视图层代码,移除GraphView中不必要的模板和计算逻辑
1 parent 3f7e70d commit c5dde79

File tree

4 files changed

+78
-240
lines changed

4 files changed

+78
-240
lines changed

web/src/components/GraphCanvas.vue

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@
88
<div class="canvas-content">
99
<slot name="content" />
1010
</div>
11+
<!-- Statistical Info Panel -->
12+
<div class="graph-stats-panel" v-if="graphData.nodes.length > 0">
13+
<div class="stat-item">
14+
<span class="stat-label">节点</span>
15+
<span class="stat-value">{{ graphData.nodes.length }}</span>
16+
<span v-if="graphInfo?.node_count" class="stat-total">/ {{ graphInfo.node_count }}</span>
17+
</div>
18+
<div class="stat-item">
19+
<span class="stat-label">边</span>
20+
<span class="stat-value">{{ graphData.edges.length }}</span>
21+
<span v-if="graphInfo?.edge_count" class="stat-total">/ {{ graphInfo.edge_count }}</span>
22+
</div>
23+
</div>
1124
<div v-if="$slots.bottom" class="overlay bottom">
1225
<slot name="bottom" />
1326
</div>
@@ -26,6 +39,10 @@ const props = defineProps({
2639
required: true,
2740
default: () => ({ nodes: [], edges: [] })
2841
},
42+
graphInfo: {
43+
type: Object,
44+
default: () => ({})
45+
},
2946
labelField: { type: String, default: 'name' },
3047
autoFit: { type: Boolean, default: true },
3148
autoResize: { type: Boolean, default: true },
@@ -423,6 +440,45 @@ defineExpose({
423440
height: 100%;
424441
}
425442
443+
.graph-stats-panel {
444+
position: absolute;
445+
bottom: 20px;
446+
left: 20px;
447+
display: flex;
448+
align-items: center;
449+
gap: 16px;
450+
padding: 6px 12px;
451+
background: var(--color-trans-light);
452+
border: 1px solid var(--color-border-secondary);
453+
border-radius: 8px;
454+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
455+
pointer-events: auto;
456+
z-index: 10;
457+
font-size: 13px;
458+
backdrop-filter: blur(4px);
459+
460+
.stat-item {
461+
display: flex;
462+
align-items: center;
463+
gap: 4px;
464+
465+
.stat-label {
466+
color: var(--color-text-secondary);
467+
font-weight: 500;
468+
}
469+
470+
.stat-value {
471+
color: var(--color-text);
472+
font-weight: 600;
473+
}
474+
475+
.stat-total {
476+
color: var(--color-text-quaternary);
477+
font-size: 11px;
478+
}
479+
}
480+
}
481+
426482
.slots {
427483
// 让整层覆盖容器默认不接收指针事件(便于穿透到底下画布)
428484
pointer-events: none;

web/src/components/GraphInfoPanel.vue

Lines changed: 0 additions & 131 deletions
This file was deleted.

web/src/components/LightRAGInfoPanel.vue

Lines changed: 0 additions & 74 deletions
This file was deleted.

web/src/views/GraphView.vue

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
<GraphCanvas
5151
ref="graphRef"
5252
:graph-data="graph.graphData"
53+
:graph-info="formattedGraphInfo"
5354
:highlight-keywords="[state.searchInput]"
5455
@node-click="graph.handleNodeClick"
5556
@edge-click="graph.handleEdgeClick"
@@ -94,24 +95,6 @@
9495
<template #content>
9596
<a-empty v-show="graph.graphData.nodes.length === 0" style="padding: 4rem 0;"/>
9697
</template>
97-
<template #bottom>
98-
<div class="footer">
99-
<GraphInfoPanel
100-
v-if="isNeo4j"
101-
:graph-info="graphInfo"
102-
:graph-data="graph.graphData"
103-
:unindexed-count="unindexedCount"
104-
:model-matched="modelMatched"
105-
@index-nodes="indexNodes"
106-
/>
107-
<LightRAGInfoPanel
108-
v-else
109-
:stats="state.lightragStats"
110-
:graph-data="graph.graphData"
111-
:database-name="getDatabaseName()"
112-
/>
113-
</div>
114-
</template>
11598
</GraphCanvas>
11699
<!-- 详情浮动卡片 -->
117100
<GraphDetailPanel
@@ -125,12 +108,12 @@
125108
</div>
126109

127110
<a-modal
128-
:open="state.showModal" title="上传文件"
129-
@ok="addDocumentByFile"
130-
@cancel="handleModalCancel"
131-
ok-text="添加到图数据库" cancel-text="取消"
132-
:confirm-loading="state.processing"
133-
:ok-button-props="{ disabled: !hasValidFile }">
111+
:open="state.showModal" title="上传文件"
112+
@ok="addDocumentByFile"
113+
@cancel="handleModalCancel"
114+
ok-text="添加到图数据库" cancel-text="取消"
115+
:confirm-loading="state.processing"
116+
:ok-button-props="{ disabled: !hasValidFile }">
134117
<div class="upload">
135118
<div class="note">
136119
<p>上传的文件内容参考 test/data/A_Dream_of_Red_Mansions_tiny.jsonl 中的格式:</p>
@@ -193,8 +176,6 @@ import HeaderComponent from '@/components/HeaderComponent.vue';
193176
import { neo4jApi, unifiedApi } from '@/apis/graph_api';
194177
import { useUserStore } from '@/stores/user';
195178
import GraphCanvas from '@/components/GraphCanvas.vue';
196-
import GraphInfoPanel from '@/components/GraphInfoPanel.vue';
197-
import LightRAGInfoPanel from '@/components/LightRAGInfoPanel.vue';
198179
import GraphDetailPanel from '@/components/GraphDetailPanel.vue';
199180
import UploadModal from '@/components/FileUploadModal.vue';
200181
import { useGraph } from '@/composables/useGraph';
@@ -228,13 +209,6 @@ const state = reactive({
228209
})
229210
230211
const isNeo4j = computed(() => {
231-
// 当 selectedDbId 是 'neo4j' 时,或者以 'kb_' 开头时,我们认为它是 Neo4j 驱动的
232-
// 但是对于 kb_ 开头的,我们可能想要使用 LightRAGInfoPanel 的展示风格(因为它有 stats)
233-
// 或者复用 GraphInfoPanel。
234-
// GraphInfoPanel 是为 'neo4j' 全局图设计的,包含了 model matching 检查等。
235-
// KBs (kb_*) 使用 Neo4j 存储,但逻辑上更接近 LightRAG 的"知识库"概念。
236-
// 为了让 LightRAGInfoPanel 能够展示 stats (get_stats 已经更新支持 kb_),
237-
// 我们这里让 kb_ ID 返回 false,这样会进入 LightRAGInfoPanel 分支。
238212
return state.selectedDbId === 'neo4j';
239213
});
240214
@@ -248,6 +222,20 @@ const unindexedCount = computed(() => {
248222
return graphInfo.value?.unindexed_node_count || 0;
249223
});
250224
225+
const formattedGraphInfo = computed(() => {
226+
if (isNeo4j.value) {
227+
return {
228+
node_count: graphInfo.value?.entity_count || 0,
229+
edge_count: graphInfo.value?.relationship_count || 0
230+
}
231+
} else {
232+
return {
233+
node_count: state.lightragStats?.total_nodes || 0,
234+
edge_count: state.lightragStats?.total_edges || 0
235+
}
236+
}
237+
})
238+
251239
const loadDatabases = async () => {
252240
state.loadingDatabases = true;
253241
try {
@@ -636,8 +624,7 @@ const goToDatabasePage = () => {
636624
overflow: hidden;
637625
background: var(--gray-10);
638626
639-
.actions,
640-
.footer {
627+
.actions {
641628
display: flex;
642629
justify-content: space-between;
643630
margin: 20px 0;

0 commit comments

Comments
 (0)