20260810172235
This commit is contained in:
1 parent
c4891538a7
commit
ed5ab3885d
35 files changed
+1314
-653
No files matched your search
@@ -0,0 +1,21 @@
|
||||
import * as LucideIcons from "@lucide/vue"
|
||||
|
||||
let iconMap: Record<string, any> | null = null
|
||||
|
||||
function loadIcons() {
|
||||
if (iconMap) return
|
||||
const map: Record<string, any> = {}
|
||||
for (const [key, component] of Object.entries(LucideIcons)) {
|
||||
if (key !== "default" && key !== "createLucideIcon" && typeof key === "string" && key.charAt(0) === key.charAt(0).toUpperCase()) {
|
||||
map[key] = component
|
||||
}
|
||||
}
|
||||
iconMap = map
|
||||
}
|
||||
|
||||
/** 同步获取图标组件,传入 null/空字符串时返回 null */
|
||||
export function getIcon(name?: string | null) {
|
||||
if (!iconMap) loadIcons()
|
||||
if (!name || !iconMap) return null
|
||||
return iconMap[name] || null
|
||||
}
|
||||
Reference in new issue
Block a user