refactor: 移除知识图谱统计信息的显示和相关逻辑(因为不准确)
- 在 `KnowledgeGraphSection.vue` 中,删除不准确的节点和边统计信息显示。 - 在 `KnowledgeGraphViewer.vue` 中,更新统计信息逻辑,移除对总节点和总边的依赖。 - 在 `database.js` 和 `graphStore.js` 中,移除图统计信息的初始化和重置逻辑,简化状态管理。
This commit is contained in:
parent
bf286e1f01
commit
6bc1f0e247
@ -2,10 +2,7 @@
|
|||||||
<div class="graph-section" v-if="isGraphSupported">
|
<div class="graph-section" v-if="isGraphSupported">
|
||||||
<div class="graph-toolbar">
|
<div class="graph-toolbar">
|
||||||
<div class="toolbar-left">
|
<div class="toolbar-left">
|
||||||
<div class="graph-stats">
|
<!-- 移除了不准确的总节点数和总边数显示 -->
|
||||||
<a-tag color="blue" size="small">总节点: {{ graphStats.total_nodes || 0 }}</a-tag>
|
|
||||||
<a-tag color="green" size="small">总边: {{ graphStats.total_edges || 0 }}</a-tag>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="graph-container-compact">
|
<div class="graph-container-compact">
|
||||||
@ -23,7 +20,6 @@
|
|||||||
:initial-limit="graphLimit"
|
:initial-limit="graphLimit"
|
||||||
:initial-depth="graphDepth"
|
:initial-depth="graphDepth"
|
||||||
ref="graphViewerRef"
|
ref="graphViewerRef"
|
||||||
@update:stats="handleViewerStats"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -109,10 +105,6 @@ const store = useDatabaseStore();
|
|||||||
const databaseId = computed(() => store.databaseId);
|
const databaseId = computed(() => store.databaseId);
|
||||||
const kbType = computed(() => store.database.kb_type);
|
const kbType = computed(() => store.database.kb_type);
|
||||||
const kbTypeLabel = computed(() => getKbTypeLabel(kbType.value || 'lightrag'));
|
const kbTypeLabel = computed(() => getKbTypeLabel(kbType.value || 'lightrag'));
|
||||||
const graphStats = computed({
|
|
||||||
get: () => store.graphStats,
|
|
||||||
set: (stats) => store.graphStats = stats
|
|
||||||
});
|
|
||||||
|
|
||||||
const graphViewerRef = ref(null);
|
const graphViewerRef = ref(null);
|
||||||
const showSettings = ref(false);
|
const showSettings = ref(false);
|
||||||
@ -254,19 +246,6 @@ const scheduleGraphLoad = (delay = 200) => {
|
|||||||
}, delay);
|
}, delay);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 处理子组件(Viewer)上报的统计信息,将其写入 database store 的 graphStats
|
|
||||||
const handleViewerStats = (stats) => {
|
|
||||||
if (!stats) return;
|
|
||||||
|
|
||||||
// 合并现有 store.graphStats,优先使用来自 viewer 的值
|
|
||||||
store.graphStats = {
|
|
||||||
total_nodes: stats.total_nodes ?? store.graphStats.total_nodes ?? 0,
|
|
||||||
total_edges: stats.total_edges ?? store.graphStats.total_edges ?? 0,
|
|
||||||
displayed_nodes: stats.displayed_nodes ?? store.graphStats.displayed_nodes ?? 0,
|
|
||||||
displayed_edges: stats.displayed_edges ?? store.graphStats.displayed_edges ?? 0,
|
|
||||||
is_truncated: stats.is_truncated ?? store.graphStats.is_truncated ?? false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.active,
|
() => props.active,
|
||||||
@ -279,14 +258,6 @@ watch(
|
|||||||
);
|
);
|
||||||
|
|
||||||
watch(databaseId, () => {
|
watch(databaseId, () => {
|
||||||
// 重置统计信息
|
|
||||||
store.graphStats = {
|
|
||||||
total_nodes: 0,
|
|
||||||
total_edges: 0,
|
|
||||||
displayed_nodes: 0,
|
|
||||||
displayed_edges: 0,
|
|
||||||
is_truncated: false
|
|
||||||
};
|
|
||||||
clearGraph();
|
clearGraph();
|
||||||
|
|
||||||
// 只有在新数据库支持图谱时才加载
|
// 只有在新数据库支持图谱时才加载
|
||||||
@ -297,13 +268,6 @@ watch(databaseId, () => {
|
|||||||
|
|
||||||
watch(isGraphSupported, (supported) => {
|
watch(isGraphSupported, (supported) => {
|
||||||
if (!supported) {
|
if (!supported) {
|
||||||
store.graphStats = {
|
|
||||||
total_nodes: 0,
|
|
||||||
total_edges: 0,
|
|
||||||
displayed_nodes: 0,
|
|
||||||
displayed_edges: 0,
|
|
||||||
is_truncated: false
|
|
||||||
};
|
|
||||||
clearGraph();
|
clearGraph();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -339,12 +303,6 @@ onUnmounted(() => {
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
|
|
||||||
.graph-stats {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.toolbar-right {
|
.toolbar-right {
|
||||||
|
|||||||
@ -698,13 +698,10 @@ const loadGraphData = async () => {
|
|||||||
|
|
||||||
// 设置图数据
|
// 设置图数据
|
||||||
graphStore.setRawGraph(rawGraph)
|
graphStore.setRawGraph(rawGraph)
|
||||||
// 更新 displayed 计数(当前视图)以及来自后端的 total 计数(整个库)
|
// 更新当前显示的节点和边数量
|
||||||
graphStore.stats = {
|
graphStore.stats = {
|
||||||
displayed_nodes: graphResponse.data.nodes.length,
|
displayed_nodes: graphResponse.data.nodes.length,
|
||||||
displayed_edges: graphResponse.data.edges.length,
|
displayed_edges: graphResponse.data.edges.length,
|
||||||
// 从 statsResponse 填充整个知识库的统计信息(后端返回 total_nodes/total_edges)
|
|
||||||
total_nodes: statsResponse.data.total_nodes ?? graphStore.stats.total_nodes ?? 0,
|
|
||||||
total_edges: statsResponse.data.total_edges ?? graphStore.stats.total_edges ?? 0,
|
|
||||||
is_truncated: graphResponse.data.is_truncated
|
is_truncated: graphResponse.data.is_truncated
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,14 +17,7 @@ export const useDatabaseStore = defineStore('database', () => {
|
|||||||
|
|
||||||
const queryParams = ref([]);
|
const queryParams = ref([]);
|
||||||
const meta = reactive({});
|
const meta = reactive({});
|
||||||
const graphStats = ref({
|
const selectedRowKeys = ref([]);
|
||||||
total_nodes: 0,
|
|
||||||
total_edges: 0,
|
|
||||||
displayed_nodes: 0,
|
|
||||||
displayed_edges: 0,
|
|
||||||
is_truncated: false,
|
|
||||||
});
|
|
||||||
const selectedRowKeys = ref([]);
|
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
databaseLoading: false,
|
databaseLoading: false,
|
||||||
@ -377,7 +370,6 @@ export const useDatabaseStore = defineStore('database', () => {
|
|||||||
selectedFile,
|
selectedFile,
|
||||||
queryParams,
|
queryParams,
|
||||||
meta,
|
meta,
|
||||||
graphStats,
|
|
||||||
selectedRowKeys,
|
selectedRowKeys,
|
||||||
state,
|
state,
|
||||||
getDatabaseInfo,
|
getDatabaseInfo,
|
||||||
|
|||||||
@ -27,10 +27,9 @@ export const useGraphStore = defineStore('graph', {
|
|||||||
|
|
||||||
// 图统计信息
|
// 图统计信息
|
||||||
stats: {
|
stats: {
|
||||||
total_nodes: 0,
|
|
||||||
total_edges: 0,
|
|
||||||
displayed_nodes: 0,
|
displayed_nodes: 0,
|
||||||
displayed_edges: 0
|
displayed_edges: 0,
|
||||||
|
is_truncated: false
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@ -204,10 +203,9 @@ export const useGraphStore = defineStore('graph', {
|
|||||||
updateStats() {
|
updateStats() {
|
||||||
if (this.rawGraph) {
|
if (this.rawGraph) {
|
||||||
this.stats = {
|
this.stats = {
|
||||||
total_nodes: this.rawGraph.nodes.length,
|
|
||||||
total_edges: this.rawGraph.edges.length,
|
|
||||||
displayed_nodes: this.rawGraph.nodes.length,
|
displayed_nodes: this.rawGraph.nodes.length,
|
||||||
displayed_edges: this.rawGraph.edges.length
|
displayed_edges: this.rawGraph.edges.length,
|
||||||
|
is_truncated: this.rawGraph.is_truncated ?? this.stats?.is_truncated ?? false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -417,10 +415,9 @@ export const useGraphStore = defineStore('graph', {
|
|||||||
this.moveToSelectedNode = false
|
this.moveToSelectedNode = false
|
||||||
this.graphIsEmpty = false
|
this.graphIsEmpty = false
|
||||||
this.stats = {
|
this.stats = {
|
||||||
total_nodes: 0,
|
|
||||||
total_edges: 0,
|
|
||||||
displayed_nodes: 0,
|
displayed_nodes: 0,
|
||||||
displayed_edges: 0
|
displayed_edges: 0,
|
||||||
|
is_truncated: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user