From 05b8b287a72970bacd629b93519f61fd2371c0bc Mon Sep 17 00:00:00 2001 From: zhangrenyuan <18990852002@163.com> Date: Tue, 21 Oct 2025 11:08:08 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E5=86=8D=E6=AC=A1=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E8=A7=A3=E5=86=B3=E6=89=93=E5=8C=85=E5=90=8E=E7=9A=84?= =?UTF-8?q?=E5=9B=BE=E6=A0=87=E8=8E=B7=E5=8F=96=E4=B8=8D=E6=AD=A3=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 2 +- src/views/home.vue | 26 ++++++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/.env.development b/.env.development index 6863c9d..78c0c88 100644 --- a/.env.development +++ b/.env.development @@ -11,7 +11,7 @@ VITE_UPLOAD_URL=http://39.101.133.168:8828/hljw/api/aws/upload # zhangyong # VITE_API_BASE='http://192.168.3.83:8081/' # 本地 -VITE_API_BASE='http://localhost:8081/' +# VITE_API_BASE='http://localhost:8081/' # sunjiabei # VITE_API_BASE='http://192.168.1.70:8081/' diff --git a/src/views/home.vue b/src/views/home.vue index 5e5ca41..edc44ae 100644 --- a/src/views/home.vue +++ b/src/views/home.vue @@ -10,14 +10,27 @@ 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' }) +// 使用import.meta.glob导入所有SVG图标(修复版本) +const icons = import.meta.glob('@/assets/SvgIcons/*.svg', { eager: true }) -// 创建获取图标路径的函数 +// 创建获取图标路径的函数(修复版本) const getIconPath = (menuName) => { - // 为菜单名添加.svg扩展名并在icons对象中查找 - const iconKey = `@/assets/SvgIcons/${menuName}.svg`; - return icons[iconKey] || ''; // 如果找不到,返回空字符串 + + // 构建可能的key格式 + const possibleKeys = [ + `@/assets/SvgIcons/${menuName}.svg`, + `./SvgIcons/${menuName}.svg`, + `/src/assets/SvgIcons/${menuName}.svg` + ] + + // 在icons对象中查找对应的图标 + for (const key of possibleKeys) { + if (icons[key]) { + const iconModule = icons[key] + // 返回模块的default属性或直接返回值 + return iconModule.default || iconModule + } + } } @@ -220,6 +233,7 @@ function logout() {