Skip to content

Commit d276bc9

Browse files
committed
style: 优化引用知识库样式
1 parent 3ceefa3 commit d276bc9

File tree

2 files changed

+38
-98
lines changed

2 files changed

+38
-98
lines changed

ui/src/components/ai-chat/KnowledgeSource.vue

Lines changed: 35 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,31 @@
88
>
99
</div>
1010
<div class="mt-8" v-if="!isWorkFlow(props.type)">
11-
<el-space wrap>
12-
<div v-for="(paragraph, index) in uniqueParagraphList" :key="index">
13-
<el-icon class="mr-4" :size="25">
14-
<img :src="getIconPath(paragraph.document_name)" style="width: 90%" alt="" />
15-
</el-icon>
16-
<span
17-
v-if="!paragraph.source_url"
18-
class="ellipsis"
19-
:title="paragraph?.document_name?.trim()"
20-
>
21-
{{ paragraph?.document_name }}
22-
</span>
23-
<a
24-
v-else
25-
@click="openLink(paragraph.source_url)"
26-
class="ellipsis"
27-
:title="paragraph?.document_name?.trim()"
28-
>
29-
<span :title="paragraph?.document_name?.trim()">
30-
{{ paragraph?.document_name }}
31-
</span>
32-
</a>
33-
</div>
34-
</el-space>
11+
<el-row :gutter="8" v-if="uniqueParagraphList?.length">
12+
<template v-for="(item, index) in uniqueParagraphList" :key="index">
13+
<el-col :span="12" class="mb-8">
14+
<el-card shadow="never" class="file-List-card" data-width="40">
15+
<div class="flex-between">
16+
<div class="flex">
17+
<img :src="getImgUrl(item && item?.document_name)" alt="" width="20" />
18+
<div class="ml-4" v-if="!item.source_url">
19+
<p>{{ item && item?.document_name }}</p>
20+
</div>
21+
<div class="ml-8" v-else>
22+
<a
23+
@click="openLink(item.source_url)"
24+
class="ellipsis"
25+
:title="item?.document_name?.trim()"
26+
>
27+
<span :title="item?.document_name?.trim()">{{ item?.document_name }}</span>
28+
</a>
29+
</div>
30+
</div>
31+
</div>
32+
</el-card>
33+
</el-col>
34+
</template>
35+
</el-row>
3536
</div>
3637

3738
<div class="border-t color-secondary flex-between mt-12" style="padding-top: 12px">
@@ -59,7 +60,7 @@ import { computed, ref } from 'vue'
5960
import ParagraphSourceDialog from './ParagraphSourceDialog.vue'
6061
import ExecutionDetailDialog from './ExecutionDetailDialog.vue'
6162
import { isWorkFlow } from '@/utils/application'
62-
63+
import { getImgUrl } from '@/utils/utils'
6364
const props = defineProps({
6465
data: {
6566
type: Object,
@@ -70,15 +71,6 @@ const props = defineProps({
7071
default: ''
7172
}
7273
})
73-
const iconMap: { [key: string]: string } = {
74-
doc: '../../assets/doc-icon.svg',
75-
docx: '../../assets/docx-icon.svg',
76-
pdf: '../../assets/pdf-icon.svg',
77-
md: '../../assets/md-icon.svg',
78-
txt: '../../assets/txt-icon.svg',
79-
xls: '../../assets/xls-icon.svg',
80-
xlsx: '../../assets/xlsx-icon.svg'
81-
}
8274
8375
const ParagraphSourceDialogRef = ref()
8476
const ExecutionDetailDialogRef = ref()
@@ -106,15 +98,16 @@ const uniqueParagraphList = computed(() => {
10698
}) || []
10799
)
108100
})
109-
110-
function getIconPath(documentName: string) {
111-
const extension = documentName.split('.').pop()?.toLowerCase()
112-
if (!documentName || !extension) return new URL(`${iconMap['doc']}`, import.meta.url).href
113-
if (iconMap && extension && iconMap[extension]) {
114-
return new URL(`${iconMap[extension]}`, import.meta.url).href
115-
}
116-
return new URL(`${iconMap['doc']}`, import.meta.url).href
101+
function fileType(name: string) {
102+
const suffix = name.split('.')
103+
return suffix[suffix.length - 1]
104+
}
105+
const typeList: any = {
106+
txt: ['txt', 'pdf', 'docx', 'csv', 'md', 'html'],
107+
table: ['xlsx', 'xls', 'csv'],
108+
QA: ['xlsx', 'csv', 'xls']
117109
}
110+
118111
function openLink(url: string) {
119112
// 如果url不是以/结尾,加上/
120113
if (url && !url.endsWith('/')) {

ui/src/components/ai-chat/component/ParagraphCard.vue

Lines changed: 3 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -18,45 +18,8 @@
1818
<template #footer>
1919
<div class="footer-content flex-between">
2020
<el-text class="flex align-center" style="width: 70%">
21-
<el-icon class="mr-4" :size="25">
22-
<img
23-
src="@/assets/doc-icon.svg"
24-
style="width: 90%"
25-
alt=""
26-
v-if="data?.document_name?.includes('doc')"
27-
/>
28-
<img
29-
src="@/assets/docx-icon.svg"
30-
style="width: 90%"
31-
alt=""
32-
v-else-if="data?.document_name?.includes('docx')"
33-
/>
34-
<img
35-
src="@/assets/pdf-icon.svg"
36-
style="width: 90%"
37-
alt=""
38-
v-else-if="data?.document_name?.includes('pdf')"
39-
/>
40-
<img
41-
src="@/assets/md-icon.svg"
42-
style="width: 90%"
43-
alt=""
44-
v-else-if="data?.document_name?.includes('md')"
45-
/>
46-
<img
47-
src="@/assets/xls-icon.svg"
48-
style="width: 90%"
49-
alt=""
50-
v-else-if="data?.document_name?.includes('xls')"
51-
/>
52-
<img
53-
src="@/assets/txt-icon.svg"
54-
style="width: 90%"
55-
alt=""
56-
v-else-if="data?.document_name?.includes('txt')"
57-
/>
58-
<img src="@/assets/doc-icon.svg" style="width: 90%" alt="" v-else />
59-
</el-icon>
21+
<img :src="getImgUrl(data?.document_name?.trim())" alt="" width="20" class="mr-4" />
22+
6023
<span class="ellipsis" :title="data?.document_name?.trim()">
6124
{{ data?.document_name.trim() }}</span
6225
>
@@ -73,6 +36,7 @@
7336
</CardBox>
7437
</template>
7538
<script setup lang="ts">
39+
import { getImgUrl } from '@/utils/utils'
7640
const props = defineProps({
7741
data: {
7842
type: Object,
@@ -83,23 +47,6 @@ const props = defineProps({
8347
default: 0
8448
}
8549
})
86-
const iconMap: { [key: string]: string } = {
87-
doc: '../../assets/doc-icon.svg',
88-
docx: '../../assets/docx-icon.svg',
89-
pdf: '../../assets/pdf-icon.svg',
90-
md: '../../assets/md-icon.svg',
91-
txt: '../../assets/txt-icon.svg',
92-
xls: '../../assets/xls-icon.svg',
93-
xlsx: '../../assets/xlsx-icon.svg'
94-
}
95-
function getIconPath(documentName: string) {
96-
const extension = documentName.split('.').pop()?.toLowerCase()
97-
if (!documentName || !extension) return new URL(`${iconMap['doc']}`, import.meta.url).href
98-
if (iconMap && extension && iconMap[extension]) {
99-
return new URL(`${iconMap[extension]}`, import.meta.url).href
100-
}
101-
return new URL(`${iconMap['doc']}`, import.meta.url).href
102-
}
10350
</script>
10451
<style lang="scss" scoped>
10552
.paragraph-source-card-height {

0 commit comments

Comments
 (0)