mirror of
https://github.com/fugary/simple-element-plus-template.git
synced 2025-11-12 14:27:49 +00:00
icon优化
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
|
||||
import * as MaterialIconsVue from '@vicons/material'
|
||||
import { kebabCase } from 'lodash-es'
|
||||
import { defineAsyncComponent } from 'vue'
|
||||
|
||||
export const INSTALL_ICONS = []
|
||||
export const ICON_PREFIX = 'icon-'
|
||||
|
||||
/**
|
||||
* icon组件注册工具,默认增加icon-前缀,如果重复,再增加前缀
|
||||
* @param app {import('vue').App} Vue实例
|
||||
@@ -30,8 +31,19 @@ export default {
|
||||
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
||||
registryIconComponent(app, key, component, 'El')
|
||||
}
|
||||
for (const [key, component] of Object.entries(MaterialIconsVue)) {
|
||||
registryIconComponent(app, key, component, 'Md')
|
||||
const materialIcons = import.meta.glob([
|
||||
'/node_modules/@vicons/material/es/*Filled.js',
|
||||
'/node_modules/@vicons/material/es/*Outlined.js'
|
||||
], { eager: false })
|
||||
for (const path in materialIcons) {
|
||||
const component = materialIcons[path]
|
||||
const matchResult = /.+\/(\w+)\.js/g.exec(path)
|
||||
if (matchResult[1]) {
|
||||
const name = matchResult[1]
|
||||
registryIconComponent(app, name, defineAsyncComponent(component), 'Md')
|
||||
}
|
||||
}
|
||||
// 更多图标可以再注册
|
||||
// registryIconComponent(app, key, component, 'Md')
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user