|
|
|
@ -10,6 +10,16 @@ import { storeToRefs } from 'pinia' |
|
|
|
import { filterMenu, getRoutePath } from "@/utils/menuUtils.js"; |
|
|
|
import SettingsIcon from '@/assets/blue.png'; |
|
|
|
|
|
|
|
// 使用import.meta.glob导入所有SVG图标 |
|
|
|
const icons = import.meta.glob('@/assets/SvgIcons/*.svg', { eager: true, import: 'default' }) |
|
|
|
|
|
|
|
// 创建获取图标路径的函数 |
|
|
|
const getIconPath = (menuName) => { |
|
|
|
// 为菜单名添加.svg扩展名并在icons对象中查找 |
|
|
|
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;" |
|
|
|
> |
|
|
|
|