修复图标加载失败问题,修改加载方式
This commit is contained in:
parent
631ca18ce5
commit
7f792a9ce5
|
@ -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'),
|
||||
|
|
Loading…
Reference in New Issue