Files
mokeegateway/mokee-gateway-web/src/utils/icons.ts
2026-07-15 16:13:27 +08:00

23 lines
821 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 图标注册表 — 动态图标解析
*
* 因为 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