From e37fce9555ccd0eee03a42b35509e255e8802959 Mon Sep 17 00:00:00 2001 From: zhangrenyuan <18990852002@163.com> Date: Tue, 21 Oct 2025 10:58:03 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E8=A7=A3=E5=86=B3=E6=89=93?= =?UTF-8?q?=E5=8C=85=E5=90=8E=E7=9A=84=E5=9B=BE=E6=A0=87=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E4=B8=8D=E6=AD=A3=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/home.vue | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/views/home.vue b/src/views/home.vue index 9ad8256..5e5ca41 100644 --- a/src/views/home.vue +++ b/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.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() {