diff --git a/chat-client/src/views/chatweb/components/ChatBox.vue b/chat-client/src/views/chatweb/components/ChatBox.vue index 2116a55..28c6dcb 100644 --- a/chat-client/src/views/chatweb/components/ChatBox.vue +++ b/chat-client/src/views/chatweb/components/ChatBox.vue @@ -3,7 +3,7 @@
@@ -24,7 +24,7 @@ :class="{ 'active': currentChatIndex === index }" @click="switchChat(index)" > - {{ chat.title || $t('vabI18n.chat.chat') + ` ${index + 1}` }} + {{ chat.title || t('vabI18n.chat.chat') + ` ${index + 1}` }} {{ formatTime(chat.timestamp) }}
@@ -51,14 +51,14 @@ - {{ $t('vabI18n.chat.assistant') }} +
- {{ msg.isUser ? $t('vabI18n.chat.you') : $t('vabI18n.chat.assistant') }} + {{ msg.isUser ? t('vabI18n.chat.you') : t('vabI18n.chat.assistant') }}
@@ -70,7 +70,7 @@ type="textarea" :autosize="{ minRows: 3, maxRows: 8 }" class="edit-textarea" - placeholder="{{ $t('vabI18n.chat.placeholder') }}" + :placeholder="$t('vabI18n.chat.placeholder')" @keydown.enter.ctrl="handleSaveEdit" @keydown.escape="handleCancelEdit" /> @@ -79,14 +79,14 @@ @click="handleCancelEdit" class="edit-btn cancel-btn" > - {{ $t('vabI18n.chat.cancel') }} + {{ t('vabI18n.chat.cancel') }}
@@ -101,7 +101,7 @@ - {{ $t('vabI18n.chat.think') }} + {{ t('vabI18n.chat.think') }}
{{ parseThink(msg.text).think }} @@ -137,7 +137,7 @@ - {{ $t('vabI18n.chat.sources') }} + {{ t('vabI18n.chat.sources') }}
@@ -324,7 +324,7 @@
@@ -332,7 +332,7 @@ @@ -352,7 +352,7 @@ { // 获取文件类型图标 - 使用动态导入确保路径正确 const getFileTypeIcon = (fileType: string) => { - // 使用动态导入获取图标路径 + const icons = require.context('@/assets/img/filetype-icon', false, /\.png$/) + // console.log(icons) + // console.log('所有图标 keys:', icons.keys()) + const getIconUrl = (iconName: string) => { - return new URL(require(`@/assets/img/filetype-icon/${iconName}.png`), import.meta.url).href + const fullName = `./${iconName}.png` + if (icons.keys().includes(fullName)) { + return icons(fullName) + } else { + // console.warn('图标不存在:', fullName) + return '' + } } const iconMap: Record = { diff --git a/chat-client/src/views/datasets/components/DocumentList.vue b/chat-client/src/views/datasets/components/DocumentList.vue index 42a5118..528c2f6 100644 --- a/chat-client/src/views/datasets/components/DocumentList.vue +++ b/chat-client/src/views/datasets/components/DocumentList.vue @@ -394,14 +394,19 @@ interface PdfTask { } const getFileTypeIcon = (fileType: string) => { - // 使用动态导入获取图标路径 - // const getIconUrl = (iconName: string) => { - // return new URL(require(`@/assets/img/filetype-icon/${iconName}.png`), import.meta.url).href - // } - const getIconUrl = (iconName: string) => { - return new URL(`/src/assets/img/filetype-icon/${iconName}.png`, import.meta.url).href -} + const icons = require.context('@/assets/img/filetype-icon', false, /\.png$/) + // console.log(icons) + // console.log('所有图标 keys:', icons.keys()) + const getIconUrl = (iconName: string) => { + const fullName = `./${iconName}.png` + if (icons.keys().includes(fullName)) { + return icons(fullName) + } else { + // console.warn('图标不存在:', fullName) + return '' + } + } const iconMap: Record = { 'pdf': getIconUrl('pdf'),