初始化
This commit is contained in:
22
mokee-gateway-web/src/utils/icons.ts
Normal file
22
mokee-gateway-web/src/utils/icons.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* 图标注册表 — 动态图标解析
|
||||
*
|
||||
* 因为 unplugin-vue-components 按需导入,模板中 `<component :is="iconName">` 无法通过字符串找到图标。
|
||||
* 这里导入全部 Element Plus 图标建立字符串→组件映射,供系统配置表、菜单图标等动态渲染场景使用。
|
||||
*
|
||||
* 使用场景:SystemList、SystemSelectView、MenuList、IntegrationDoc 等动态图标渲染
|
||||
*/
|
||||
import * as Icons from '@element-plus/icons-vue'
|
||||
|
||||
/**
|
||||
* 根据图标名称获取图标组件
|
||||
* @param name - 图标名称(如 "Setting"、"UserFilled")
|
||||
* @returns 图标组件对象,找不到返回 null
|
||||
*/
|
||||
export function getIconComponent(name: string | undefined | null) {
|
||||
if (!name) return null
|
||||
return (Icons as Record<string, any>)[name] || null
|
||||
}
|
||||
|
||||
export { Icons }
|
||||
export default Icons
|
||||
Reference in New Issue
Block a user