Browse Source

fix:再次修改解决打包后的图标获取不正常

zhangyong/milestone-20250913-现金管理
zhangrenyuan 1 month ago
parent
commit
05b8b287a7
  1. 2
      .env.development
  2. 26
      src/views/home.vue

2
.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/'

26
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.globSVG
const icons = import.meta.glob('@/assets/SvgIcons/*.svg', { eager: true, import: 'default' })
// 使import.meta.globSVG
const icons = import.meta.glob('@/assets/SvgIcons/*.svg', { eager: true })
//
//
const getIconPath = (menuName) => {
// .svgicons
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() {
<div class="settings-container">
<el-dropdown placement="top-start">
<span class="el-dropdown-link">
<!-- 暂时使用静态路径确保设置图标正常显示 -->
<img src="@/assets/SvgIcons/设置.svg" alt="设置" style="width: 4vh; height: 4vh" />
<span>设置中心</span>
<el-icon class="arrow-icon">

Loading…
Cancel
Save