Browse Source

fix:解决打包后的图标获取不正常

zhangyong/milestone-20250913-现金管理
zhangrenyuan 1 month ago
parent
commit
e37fce9555
  1. 15
      src/views/home.vue

15
src/views/home.vue

@ -10,6 +10,16 @@ import { storeToRefs } from 'pinia'
import { filterMenu, getRoutePath } from "@/utils/menuUtils.js";
import SettingsIcon from '@/assets/blue.png';
// 使import.meta.globSVG
const icons = import.meta.glob('@/assets/SvgIcons/*.svg', { eager: true, import: 'default' })
//
const getIconPath = (menuName) => {
// .svgicons
const iconKey = `@/assets/SvgIcons/${menuName}.svg`;
return icons[iconKey] || ''; //
}
// -----------------------------------
@ -87,7 +97,6 @@ function findBestMatch(menuList, path) {
return bestMatch || path // fallback
}
// require
@ -156,7 +165,7 @@ function logout() {
<el-sub-menu v-if="menu.children && menu.children.length > 0" :index="menu.id.toString()">
<template #title>
<img
:src="`/src/assets/SvgIcons/${menu.menuName}.svg`"
:src="getIconPath(menu.menuName)"
:alt="`${menu.menuName}图标`"
style="width: 4vh; height: 4vh; margin-right: 4px;"
>
@ -197,7 +206,7 @@ function logout() {
<!-- 无子菜单的一级菜单 -->
<el-menu-item v-else :index="getRoutePath(menu)">
<img
:src="`@/assets/SvgIcons/${menu.menuName}.svg`"
:src="getIconPath(menu.menuName)"
:alt="`${menu.menuName}图标`"
style="width: 4vh; height: 4vh; margin-right: 4px;"
>

Loading…
Cancel
Save