修复图标加载失败问题,修改加载方式

This commit is contained in:
WangJing 2025-07-29 15:16:51 +08:00
parent 631ca18ce5
commit 7f792a9ce5
1 changed files with 12 additions and 7 deletions

View File

@ -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<string, string> = {
'pdf': getIconUrl('pdf'),