添加自定义 icon

This commit is contained in:
GGJ
2024-04-07 13:43:30 +08:00
parent a43dd0f62f
commit 266da2405f
198 changed files with 298 additions and 68 deletions

View File

@@ -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')
}
})
})
}