Skip to content

Commit 75a7d46

Browse files
committed
refactor(ui): 移除导出数据按钮并优化上传文件提示
重构多个面板组件,移除重复的导出数据按钮和相关样式代码 在GraphView中添加上传文件提示弹窗,根据数据库类型显示不同提示信息
1 parent cb9edfd commit 75a7d46

File tree

4 files changed

+89
-102
lines changed

4 files changed

+89
-102
lines changed

web/src/components/GraphDetailPanel.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const filteredEdgeProperties = computed(() => {
9797
9898
<style scoped lang="less">
9999
.detail-card {
100-
position: fixed; // 改为 fixed,避免影响父组件布局
100+
position: absolute; // 改为 fixed,避免影响父组件布局
101101
top: 80px;
102102
right: 24px;
103103
width: 300px;

web/src/components/GraphInfoPanel.vue

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@
1212
<span v-if="graphInfo?.relationship_count" class="info-total">/ {{ graphInfo.relationship_count }}</span>
1313
</div>
1414

15-
<div v-if="graphInfo?.graph_name" class="info-item">
16-
<span class="info-label">图谱</span>
17-
<span class="info-value">{{ graphInfo.graph_name }}</span>
18-
</div>
19-
15+
2016
<div v-if="unindexedCount > 0" class="info-item warning">
2117
<span class="info-label">未索引</span>
2218
<span class="info-value warning">{{ unindexedCount }}</span>
@@ -35,17 +31,10 @@
3531
</a-tooltip>
3632
</div>
3733

38-
<div class="actions">
39-
<a-button type="default" size="small" @click="$emit('export-data')">
40-
<ExportOutlined />
41-
导出数据
42-
</a-button>
4334
</div>
44-
</div>
4535
</template>
4636

4737
<script setup>
48-
import { ExportOutlined } from '@ant-design/icons-vue'
4938
5039
const props = defineProps({
5140
graphInfo: {
@@ -66,7 +55,7 @@ const props = defineProps({
6655
}
6756
})
6857
69-
defineEmits(['index-nodes', 'export-data'])
58+
defineEmits(['index-nodes'])
7059
</script>
7160

7261
<style lang="less" scoped>
@@ -120,40 +109,6 @@ defineEmits(['index-nodes', 'export-data'])
120109
font-size: 12px;
121110
}
122111
123-
.actions {
124-
margin-left: auto;
125-
display: flex;
126-
gap: 8px;
127-
128-
@media (max-width: 768px) {
129-
margin-left: 0;
130-
width: 100%;
131-
justify-content: flex-end;
132-
}
133-
}
134-
135-
:deep(.ant-btn-default) {
136-
font-size: 12px;
137-
height: 28px;
138-
padding: 0 12px;
139-
border-radius: 6px;
140-
border-color: var(--main-300);
141-
color: var(--main-600);
142-
background: var(--main-20);
143-
transition: all 0.2s ease;
144-
145-
&:hover {
146-
border-color: var(--main-500);
147-
color: var(--main-700);
148-
background: var(--main-40);
149-
box-shadow: 0 2px 4px rgba(1, 97, 121, 0.1);
150-
}
151-
152-
&:active {
153-
transform: translateY(1px);
154-
}
155-
}
156-
157112
:deep(.ant-btn-primary) {
158113
font-size: 12px;
159114
height: 28px;

web/src/components/LightRAGInfoPanel.vue

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,11 @@
1010
<span class="info-value">{{ stats?.total_edges || 0 }}</span>
1111
</div>
1212

13-
<div class="info-item">
14-
<span class="info-label">知识库</span>
15-
<span class="info-value">{{ databaseName }}</span>
16-
</div>
17-
18-
<div class="actions">
19-
<a-button type="default" size="small" @click="$emit('export-data')">
20-
<ExportOutlined />
21-
导出数据
22-
</a-button>
23-
</div>
24-
</div>
13+
14+
</div>
2515
</template>
2616

2717
<script setup>
28-
import { ExportOutlined } from '@ant-design/icons-vue'
2918
import { computed } from 'vue'
3019
3120
const props = defineProps({
@@ -43,7 +32,6 @@ const props = defineProps({
4332
}
4433
})
4534
46-
defineEmits(['export-data'])
4735
</script>
4836

4937
<style lang="less" scoped>
@@ -83,38 +71,4 @@ defineEmits(['export-data'])
8371
color: var(--gray-1000);
8472
font-weight: 600;
8573
}
86-
87-
.actions {
88-
margin-left: auto;
89-
display: flex;
90-
gap: 8px;
91-
92-
@media (max-width: 768px) {
93-
margin-left: 0;
94-
width: 100%;
95-
justify-content: flex-end;
96-
}
97-
}
98-
99-
:deep(.ant-btn-default) {
100-
font-size: 12px;
101-
height: 28px;
102-
padding: 0 12px;
103-
border-radius: 6px;
104-
border-color: var(--main-300);
105-
color: var(--main-600);
106-
background: var(--main-20);
107-
transition: all 0.2s ease;
108-
109-
&:hover {
110-
border-color: var(--main-500);
111-
color: var(--main-700);
112-
background: var(--main-40);
113-
box-shadow: 0 2px 4px rgba(1, 97, 121, 0.1);
114-
}
115-
116-
&:active {
117-
transform: translateY(1px);
118-
}
119-
}
12074
</style>

web/src/views/GraphView.vue

Lines changed: 84 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,14 @@
3030
<!-- <a-button type="default" @click="openLink('http://localhost:7474/')" :icon="h(GlobalOutlined)">
3131
Neo4j 浏览器
3232
</a-button> -->
33-
<a-button type="primary" @click="state.showModal = true" ><UploadOutlined/> 上传文件</a-button>
33+
<a-button
34+
v-if="isNeo4j"
35+
type="primary"
36+
@click="state.showModal = true" ><UploadOutlined/> 上传文件</a-button>
37+
<a-button
38+
v-else
39+
type="primary"
40+
@click="state.showUploadTipModal = true" ><UploadOutlined/> 上传文件</a-button>
3441
<a-button v-if="unindexedCount > 0" type="primary" @click="indexNodes" :loading="state.indexing">
3542
<SyncOutlined v-if="!state.indexing"/> 为{{ unindexedCount }}个节点添加索引
3643
</a-button>
@@ -73,6 +80,9 @@
7380
</a-input>
7481
</div>
7582
<div class="actions-right">
83+
<a-button type="default" @click="exportGraphData" :icon="h(ExportOutlined)">
84+
导出数据
85+
</a-button>
7686
<a-button type="default" @click="state.showInfoModal = true" :icon="h(InfoCircleOutlined)">
7787
说明
7888
</a-button>
@@ -91,14 +101,12 @@
91101
:unindexed-count="unindexedCount"
92102
:model-matched="modelMatched"
93103
@index-nodes="indexNodes"
94-
@export-data="exportGraphData"
95104
/>
96105
<LightRAGInfoPanel
97106
v-else
98107
:stats="state.lightragStats"
99108
:graph-data="graph.graphData"
100109
:database-name="getDatabaseName()"
101-
@export-data="exportGraphData"
102110
/>
103111
</div>
104112
</template>
@@ -144,6 +152,32 @@
144152
</div>
145153
</a-modal>
146154

155+
<!-- 上传提示弹窗 -->
156+
<a-modal
157+
:open="state.showUploadTipModal"
158+
title="文件上传说明"
159+
@cancel="() => state.showUploadTipModal = false"
160+
:footer="null"
161+
width="500px"
162+
>
163+
<div class="upload-tip-content">
164+
<a-alert
165+
:message="getUploadTipMessage()"
166+
type="info"
167+
show-icon
168+
style="margin-bottom: 16px;"
169+
/>
170+
<div v-if="!isNeo4j" class="upload-tip-actions">
171+
<p>如需上传文档到当前选中的知识库,请前往对应的知识库详情页面进行操作:</p>
172+
<div class="action-buttons">
173+
<a-button type="primary" @click="goToDatabasePage">
174+
<DatabaseOutlined/> 前往知识库详情页
175+
</a-button>
176+
</div>
177+
</div>
178+
</div>
179+
</a-modal>
180+
147181
<!-- 说明弹窗 -->
148182
<a-modal
149183
:open="state.showInfoModal"
@@ -176,9 +210,10 @@
176210

177211
<script setup>
178212
import { computed, onMounted, reactive, ref, h } from 'vue';
213+
import { useRouter } from 'vue-router';
179214
import { message } from 'ant-design-vue';
180215
import { useConfigStore } from '@/stores/config';
181-
import { UploadOutlined, SyncOutlined, GlobalOutlined, InfoCircleOutlined, SearchOutlined, ReloadOutlined, LoadingOutlined, HighlightOutlined } from '@ant-design/icons-vue';
216+
import { UploadOutlined, SyncOutlined, GlobalOutlined, InfoCircleOutlined, SearchOutlined, ReloadOutlined, LoadingOutlined, HighlightOutlined, DatabaseOutlined, ExportOutlined } from '@ant-design/icons-vue';
182217
import HeaderComponent from '@/components/HeaderComponent.vue';
183218
import { neo4jApi, unifiedApi } from '@/apis/graph_api';
184219
import { useUserStore } from '@/stores/user';
@@ -193,6 +228,7 @@ const configStore = useConfigStore();
193228
const cur_embed_model = computed(() => configStore.config?.embed_model);
194229
const modelMatched = computed(() => !graphInfo?.value?.embed_model_name || graphInfo.value.embed_model_name === cur_embed_model.value)
195230
231+
const router = useRouter();
196232
const graphRef = ref(null)
197233
const graphInfo = ref(null)
198234
const fileList = ref([]);
@@ -207,6 +243,7 @@ const state = reactive({
207243
searchLoading: false,
208244
showModal: false,
209245
showInfoModal: false,
246+
showUploadTipModal: false,
210247
processing: false,
211248
indexing: false,
212249
showPage: true,
@@ -458,6 +495,33 @@ const getDatabaseName = () => {
458495
return selectedDb ? selectedDb.label : state.selectedDbId;
459496
};
460497
498+
const getUploadTipMessage = () => {
499+
if (isNeo4j.value) {
500+
return 'Neo4j 图数据库支持通过上传 JSONL 格式文件直接导入实体和关系数据。';
501+
} else {
502+
const selectedDb = state.dbOptions.find(db => db.value === state.selectedDbId);
503+
const dbType = selectedDb?.type || '未知';
504+
const dbName = selectedDb?.label || getDatabaseName();
505+
return `当前选择的是 ${dbType.toUpperCase()} 类型的知识库"${dbName}",该类型知识库需要在文档知识库页面上传文档,系统会自动从中提取知识图谱。`;
506+
}
507+
};
508+
509+
const goToDatabasePage = () => {
510+
state.showUploadTipModal = false;
511+
512+
// 如果不是 Neo4j,需要找到对应的知识库 ID 并跳转
513+
if (!isNeo4j.value) {
514+
const selectedDb = state.dbOptions.find(db => db.value === state.selectedDbId);
515+
if (selectedDb && selectedDb.type !== 'neo4j') {
516+
// 跳转到对应的知识库详情页面
517+
router.push(`/database/${state.selectedDbId}`);
518+
} else {
519+
// 如果找不到对应的数据库,跳转到数据库列表页面
520+
router.push('/database');
521+
}
522+
}
523+
};
524+
461525
</script>
462526
463527
<style lang="less" scoped>
@@ -478,9 +542,8 @@ const getDatabaseName = () => {
478542
margin-right: 20px;
479543
480544
.label {
545+
font-size: 14px;
481546
margin-right: 8px;
482-
font-weight: 500;
483-
color: var(--color-text-secondary);
484547
}
485548
}
486549
@@ -579,4 +642,19 @@ const getDatabaseName = () => {
579642
box-shadow: none;
580643
}
581644
}
645+
646+
.upload-tip-content {
647+
.upload-tip-actions {
648+
p {
649+
margin-bottom: 16px;
650+
color: var(--color-text-secondary);
651+
}
652+
}
653+
654+
.action-buttons {
655+
display: flex;
656+
justify-content: center;
657+
margin-top: 20px;
658+
}
659+
}
582660
</style>

0 commit comments

Comments
 (0)