+
+
+
{{ $t('common.loading') }}
-
+
{{ $t('agent.artifactDrawer.empty') }}
-
-
-
-
-
+
+ -
+
+
+
{{ item.file_name }}
@@ -49,19 +57,20 @@
-
-
- {{ $t('agent.artifactDrawer.download') }}
-
+
+
+
-
-
+
+
@@ -83,6 +92,7 @@ import { computed, ref, watch, reactive } from 'vue'
import { useI18n } from 'vue-i18n'
import { MessagePlugin } from 'tdesign-vue-next'
import { downloadArtifact, listMessageArtifacts, type ArtifactMeta } from '@/api/chat'
+import { getFileIcon } from '@/utils/files'
const props = defineProps<{
visible: boolean
@@ -144,7 +154,6 @@ function handleClose() {
emit('update:visible', false)
}
-// Format helpers.
function formatFileSize(size: number): string {
if (!size || size < 0) return '0 B'
const units = ['B', 'KB', 'MB', 'GB']
@@ -154,7 +163,6 @@ function formatFileSize(size: number): string {
s /= 1024
unit++
}
- // Keep one decimal for non-integer units; integers stay integer.
return unit === 0 ? `${s} ${units[unit]}` : `${s.toFixed(1)} ${units[unit]}`
}
@@ -162,59 +170,10 @@ function formatDateTime(raw: string): string {
if (!raw) return '—'
const d = new Date(raw)
if (Number.isNaN(d.getTime())) return raw
- // Local time, seconds precision — matches how the rest of the app
- // renders message timestamps.
const pad = (n: number) => String(n).padStart(2, '0')
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`
}
-function iconForFile(name: string): string {
- const ext = (name.split('.').pop() || '').toLowerCase()
- switch (ext) {
- case 'pptx':
- case 'ppt':
- return 'chart-pie'
- case 'xlsx':
- case 'xls':
- case 'csv':
- return 'file-excel'
- case 'docx':
- case 'doc':
- return 'file-word'
- case 'pdf':
- return 'file-pdf'
- case 'md':
- case 'markdown':
- return 'file'
- case 'html':
- case 'htm':
- return 'code-1'
- case 'json':
- return 'code-1'
- case 'png':
- case 'jpg':
- case 'jpeg':
- case 'gif':
- case 'svg':
- case 'webp':
- return 'image'
- case 'mp3':
- case 'wav':
- case 'ogg':
- return 'sound-up'
- case 'mp4':
- case 'mov':
- case 'webm':
- return 'video'
- case 'zip':
- case 'tar':
- case 'gz':
- return 'folder-zip'
- default:
- return 'file-attachment'
- }
-}
-
async function handleDownload(item: ArtifactMeta) {
if (!props.sessionId || !props.messageId) {
MessagePlugin.error(t('agent.artifactDrawer.downloadFailed'))
@@ -245,6 +204,39 @@ async function handleDownload(item: ArtifactMeta) {
+
+