|
|
@ -9,20 +9,24 @@ import { iconComponents } from "/@/plugins/element-plus"; |
|
|
|
* @returns component |
|
|
|
*/ |
|
|
|
export function findIconReg(icon: string) { |
|
|
|
// fontawesome
|
|
|
|
const faReg = /^FA-/; |
|
|
|
// fontawesome4
|
|
|
|
const fa4Reg = /^fa-/; |
|
|
|
// fontawesome5+
|
|
|
|
const fa5Reg = /^FA-/; |
|
|
|
// iconfont
|
|
|
|
const iFReg = /^IF-/; |
|
|
|
// remixicon
|
|
|
|
const riReg = /^RI-/; |
|
|
|
// typeof icon === "function" 属于SVG
|
|
|
|
if (faReg.test(icon)) { |
|
|
|
const text = icon.split(faReg)[1]; |
|
|
|
if (fa5Reg.test(icon)) { |
|
|
|
const text = icon.split(fa5Reg)[1]; |
|
|
|
return findIcon( |
|
|
|
text.slice(0, text.indexOf(" ")), |
|
|
|
text.slice(0, text.indexOf(" ") == -1 ? text.length : text.indexOf(" ")), |
|
|
|
"FA", |
|
|
|
text.slice(text.indexOf(" ") + 1, text.length) |
|
|
|
); |
|
|
|
} else if (fa4Reg.test(icon)) { |
|
|
|
return findIcon(icon.split(fa4Reg)[1], "fa"); |
|
|
|
} else if (iFReg.test(icon)) { |
|
|
|
return findIcon(icon.split(iFReg)[1], "IF"); |
|
|
|
} else if (typeof icon === "function") { |
|
|
@ -45,6 +49,14 @@ export function findIcon(icon: String, type = "EL", property?: string) { |
|
|
|
components: { FontAwesomeIcon }, |
|
|
|
template: `<font-awesome-icon :icon="icon" v-bind:[property]="true" />` |
|
|
|
}); |
|
|
|
} else if (type === "fa") { |
|
|
|
return defineComponent({ |
|
|
|
name: "faIcon", |
|
|
|
data() { |
|
|
|
return { icon: `fa ${icon}` }; |
|
|
|
}, |
|
|
|
template: `<i :class="icon" />` |
|
|
|
}); |
|
|
|
} else if (type === "IF") { |
|
|
|
return defineComponent({ |
|
|
|
name: "IfIcon", |
|
|
|