From 7f792a9ce551ad0a9b9b0c2fae08cec408ddf138 Mon Sep 17 00:00:00 2001 From: WangJing Date: Tue, 29 Jul 2025 15:16:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9B=BE=E6=A0=87=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98,=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=8A=A0=E8=BD=BD=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datasets/components/DocumentList.vue | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/chat-client/src/views/datasets/components/DocumentList.vue b/chat-client/src/views/datasets/components/DocumentList.vue index a99d9e3..cbc7401 100644 --- a/chat-client/src/views/datasets/components/DocumentList.vue +++ b/chat-client/src/views/datasets/components/DocumentList.vue @@ -339,14 +339,19 @@ const renameForm = reactive({ }) 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'),