添加自定义 icon
This commit is contained in:
@@ -22,7 +22,6 @@ export function getElementPlusIconfontNames() {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取Vite开发服务/编译后的样式表内容
|
||||
* @param devID style 标签的 viteDevId,只开发服务有
|
||||
@@ -48,7 +47,6 @@ function getStylesFromVite(devId: string) {
|
||||
return sheets
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 获取 Awesome-Iconfont 的 name 列表
|
||||
*/
|
||||
@@ -67,9 +65,15 @@ export function getAwesomeIconfontNames() {
|
||||
if (/^\.fa-(.*)::before$/g.test(rules[k].selectorText)) {
|
||||
if (rules[k].selectorText.indexOf(', ') > -1) {
|
||||
const iconNames = rules[k].selectorText.split(', ')
|
||||
iconfonts.push(`${iconNames[0].substring(1, iconNames[0].length).replace(/\:\:before/gi, '')}`)
|
||||
iconfonts.push(
|
||||
`${iconNames[0].substring(1, iconNames[0].length).replace(/\:\:before/gi, '')}`
|
||||
)
|
||||
} else {
|
||||
iconfonts.push(`${rules[k].selectorText.substring(1, rules[k].selectorText.length).replace(/\:\:before/gi, '')}`)
|
||||
iconfonts.push(
|
||||
`${rules[k].selectorText
|
||||
.substring(1, rules[k].selectorText.length)
|
||||
.replace(/\:\:before/gi, '')}`
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -83,3 +87,26 @@ export function getAwesomeIconfontNames() {
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取本地自带的图标
|
||||
* /src/assets/icons文件夹内的svg文件
|
||||
*/
|
||||
export function getLocalIconfontNames() {
|
||||
return new Promise<string[]>((resolve, reject) => {
|
||||
nextTick(() => {
|
||||
let iconfonts: string[] = []
|
||||
|
||||
const svgEl = document.getElementById('local-icon')
|
||||
if (svgEl?.dataset.iconName) {
|
||||
iconfonts = (svgEl?.dataset.iconName as string).split(',')
|
||||
}
|
||||
|
||||
if (iconfonts.length > 0) {
|
||||
resolve(iconfonts)
|
||||
} else {
|
||||
reject('No Icons')
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user