diff --git a/web/src/components/RefsComponent.vue b/web/src/components/RefsComponent.vue index 895411f9..ef2bbd0e 100644 --- a/web/src/components/RefsComponent.vue +++ b/web/src/components/RefsComponent.vue @@ -6,11 +6,11 @@ {{ filename }}
-

文件名: {{ results[0].file.filename }}

+

文件名: {{ filename }}

文件类型: {{ results[0].file.type }}

创建时间: {{ new Date(results[0].file.created_at * 1000).toLocaleString() }}

@@ -47,7 +47,7 @@ diff --git a/web/src/views/GraphView.vue b/web/src/views/GraphView.vue index 53d0d8d5..9f4933f3 100644 --- a/web/src/views/GraphView.vue +++ b/web/src/views/GraphView.vue @@ -10,18 +10,18 @@
-

图数据库 {{ graph?.database_name }}

+

图数据库 {{ graphInfo?.database_name }}

- 加载中 - + 加载中 + - {{ graph?.status }} · - 共 {{ graph?.entity_count }} 实体,{{ graph?.relationship_count }} 个关系 + {{ graphInfo?.status }} · + 共 {{ graphInfo?.entity_count }} 实体,{{ graphInfo?.relationship_count }} 个关系

- 上传文件 + 上传文件

点击或者把文件拖拽到这里上传

- 目前仅支持上传文本文件,如 .pdf, .txt, .md。且同名文件无法重复添加。 + 目前仅支持上传 jsonl 文件。且同名文件无法重复添加。

- 确定 + 获取节点
-
+
{ - state.graphloading = true +const loadGraphInfo = () => { + state.loadingGraphInfo = true fetch('/api/database/graph', { method: "GET", }) .then(response => response.json()) .then(data => { console.log(data) - graph.value = data.graph - state.graphloading = false + graphInfo.value = data.graph + state.loadingGraphInfo = false }) .catch(error => { console.error(error) message.error(error.message) - state.graphloading = false + state.loadingGraphInfo = false }) } -const graphData = computed(() => { +const getGraphData = () => { return { - nodes: subgraph.nodes.map(node => { + nodes: graphData.nodes.map(node => { return { id: node.id, data: { @@ -126,7 +127,7 @@ const graphData = computed(() => { }, } }), - edges: subgraph.edges.map(edge => { + edges: graphData.edges.map(edge => { return { source: edge.source_id, target: edge.target_id, @@ -136,7 +137,7 @@ const graphData = computed(() => { } }), } -}) +} const addDocumentByFile = () => { state.precessing = true @@ -168,13 +169,10 @@ const loadSampleNodes = () => { } }) .then((data) => { - subgraph.nodes = data.result.nodes - subgraph.edges = data.result.edges - console.log(data) - console.log(subgraph) - setTimeout(() => { - randerGraph() - }, 500) + graphData.nodes = data.result.nodes + graphData.edges = data.result.edges + console.log(graphData) + randerGraph() }) .catch((error) => { message.error(error.message); @@ -197,10 +195,10 @@ const onSearch = () => { } }) .then((data) => { - subgraph.nodes = data.result.nodes - subgraph.edges = data.result.edges + graphData.nodes = data.result.nodes + graphData.edges = data.result.edges console.log(data) - console.log(subgraph) + console.log(graphData) randerGraph() }) .catch((error) => { @@ -210,54 +208,58 @@ const onSearch = () => { }; const randerGraph = () => { - graphInstance.setData(graphData.value); + + if (graphInstance) { + graphInstance.destroy(); + } + + initGraph(); + graphInstance.setData(getGraphData()); graphInstance.render(); } +const initGraph = () => { + graphInstance = new Graph({ + container: container.value, + width: container.value.offsetWidth, + height: container.value.offsetHeight, + autoFit: true, + autoResize: true, + layout: { + type: 'd3-force', + preventOverlap: true, + kr: 20, + collide: { + strength: 1.0, + }, + }, + node: { + type: 'circle', + style: { + labelText: (d) => d.data.label, + size: 70, + }, + palette: { + field: 'label', + color: 'tableau', + }, + }, + edge: { + type: 'line', + style: { + labelText: (d) => d.data.label, + labelBackground: '#fff', + endArrow: true, + }, + }, + behaviors: ['drag-element', 'zoom-canvas', 'drag-canvas'], + }); + window.addEventListener('resize', randerGraph); +} + onMounted(() => { - loadGraph(); + loadGraphInfo(); loadSampleNodes(); - setTimeout(() => { - if (state.showPage) { - graphInstance = new Graph({ - container: container.value, - width: container.value.offsetWidth, - height: container.value.offsetHeight, - autoFit: true, - autoResize: true, - layout: { - type: 'd3-force', - preventOverlap: true, - kr: 100, - collide: { - strength: 0.5, - }, - }, - node: { - type: 'circle', - style: { - labelText: (d) => d.data.label, - size: 40, - }, - palette: { - field: 'label', - color: 'tableau', - }, - }, - edge: { - type: 'line', - style: { - labelText: (d) => d.data.label, - labelBackground: '#fff', - }, - }, - behaviors: ['drag-element', 'zoom-canvas', 'drag-canvas'], - }); - graphInstance.setData(graphData.value); - graphInstance.render(); - window.addEventListener('resize', randerGraph); - } - }, 400) }); @@ -303,7 +305,7 @@ const handleDrop = (event) => { justify-content: space-between; margin-bottom: 20px; - .actions-left { + .actions-left, .actions-right { display: flex; align-items: center; gap: 10px; @@ -311,7 +313,6 @@ const handleDrop = (event) => { input { width: 100px; - margin-right: 10px; border-radius: 8px; padding: 4px 12px; border: 2px solid var(--main-300); @@ -324,6 +325,7 @@ const handleDrop = (event) => { } button { + border-width: 2px; height: 40px; box-shadow: none; } diff --git a/web/src/views/SettingView.vue b/web/src/views/SettingView.vue index aef7d244..54b150d2 100644 --- a/web/src/views/SettingView.vue +++ b/web/src/views/SettingView.vue @@ -42,7 +42,8 @@
- {{ items?.embed_model.des }}   + + {{ items?.embed_model.des }}   需要重启 @@ -58,7 +59,8 @@
- {{ items?.reranker.des }}   + + {{ items?.reranker.des }}   需要重启 @@ -89,7 +91,11 @@ />
- {{ items?.enable_knowledge_graph.des }} + {{ items?.enable_knowledge_graph.des }} + + 需要重启 + + { .label { margin-right: 20px; + + button { + margin-left: 10px; + height: 24px; + padding: 0 8px; + font-size: smaller; + } } }