Skip to content

Commit c4722ce

Browse files
committed
feat: add media display for images, audio, video, and other files in chat
--bug=1065188 --user=刘瑞斌 【应用】高级编排对话,上传的图片没有在对话中显示 https://www.tapd.cn/62980211/s/1821084
1 parent 57f6ce8 commit c4722ce

File tree

1 file changed

+70
-1
lines changed
  • ui/src/components/ai-chat/component/question-content

1 file changed

+70
-1
lines changed

ui/src/components/ai-chat/component/question-content/index.vue

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,75 @@
2424
</template>
2525
</el-space>
2626
</div>
27-
27+
<div class="mb-8" v-if="image_list.length">
28+
<el-space wrap>
29+
<template v-for="(item, index) in image_list" :key="index">
30+
<div class="file cursor border-r-6" v-if="item.url">
31+
<el-image
32+
:src="item.url"
33+
:zoom-rate="1.2"
34+
:max-scale="7"
35+
:min-scale="0.2"
36+
:preview-src-list="getAttrsArray(image_list, 'url')"
37+
:initial-index="index"
38+
alt=""
39+
fit="cover"
40+
style="width: 170px; height: 170px; display: block"
41+
class="border-r-6"
42+
/>
43+
</div>
44+
</template>
45+
</el-space>
46+
</div>
47+
<div class="mb-8" v-if="audio_list.length">
48+
<el-space wrap>
49+
<template v-for="(item, index) in audio_list" :key="index">
50+
<div class="file cursor border-r-6" v-if="item.url">
51+
<audio
52+
:src="item.url"
53+
controls
54+
style="width: 350px; height: 43px"
55+
class="border-r-6"
56+
/>
57+
</div>
58+
</template>
59+
</el-space>
60+
</div>
61+
<div class="mb-8" v-if="video_list.length">
62+
<el-space wrap>
63+
<template v-for="(item, index) in video_list" :key="index">
64+
<div class="file cursor border-r-6" v-if="item.url">
65+
<video
66+
:src="item.url"
67+
style="width: 170px; display: block"
68+
class="border-r-6"
69+
controls
70+
autoplay
71+
/>
72+
</div>
73+
</template>
74+
</el-space>
75+
</div>
76+
<div class="mb-8" v-if="other_list.length">
77+
<el-space wrap class="w-full media-file-width">
78+
<template v-for="(item, index) in other_list" :key="index">
79+
<el-card shadow="never" style="--el-card-padding: 8px" class="download-file cursor">
80+
<div class="download-button flex align-center" @click="downloadFile(item)">
81+
<el-icon class="mr-4">
82+
<Download/>
83+
</el-icon>
84+
{{ $t('chat.download') }}
85+
</div>
86+
<div class="show flex align-center">
87+
<img :src="getImgUrl(item && item?.name)" alt="" width="24"/>
88+
<div class="ml-4 ellipsis-1" :title="item && item?.name">
89+
{{ item && item?.name }}
90+
</div>
91+
</div>
92+
</el-card>
93+
</template>
94+
</el-space>
95+
</div>
2896
<span> {{ chatRecord.problem_text }}</span>
2997
</div>
3098
</div>
@@ -122,6 +190,7 @@ import { type chatType } from '@/api/type/application'
122190
import { getImgUrl, downloadByURL } from '@/utils/common'
123191
import { useRoute, useRouter } from 'vue-router'
124192
import { onMounted, computed, ref, nextTick } from 'vue'
193+
import {getAttrsArray} from '@/utils/array'
125194
import { copyClick } from '@/utils/clipboard'
126195
const route = useRoute()
127196
const {

0 commit comments

Comments
 (0)