Browse Source

perf: 同步完整版分支代码

i18n
xiaoxian521 3 years ago
parent
commit
f83aba02d8
  1. 14
      src/components/ReIcon/index.ts

14
src/components/ReIcon/index.ts

@ -13,6 +13,8 @@ export function findIconReg(icon: string) {
const faReg = /^FA-/; const faReg = /^FA-/;
// iconfont // iconfont
const iFReg = /^IF-/; const iFReg = /^IF-/;
// remixicon
const riReg = /^RI-/;
// typeof icon === "function" 属于SVG // typeof icon === "function" 属于SVG
if (faReg.test(icon)) { if (faReg.test(icon)) {
const text = icon.split(faReg)[1]; const text = icon.split(faReg)[1];
@ -25,12 +27,14 @@ export function findIconReg(icon: string) {
return findIcon(icon.split(iFReg)[1], "IF"); return findIcon(icon.split(iFReg)[1], "IF");
} else if (typeof icon === "function") { } else if (typeof icon === "function") {
return findIcon(icon, "SVG"); return findIcon(icon, "SVG");
} else if (riReg.test(icon)) {
return findIcon(icon.split(riReg)[1], "RI");
} else { } else {
return findIcon(icon, "EL"); return findIcon(icon, "EL");
} }
} }
// 支持fontawesome、iconfont、element-plus/icons、自定义svg
// 支持fontawesome、iconfont、remixicon、element-plus/icons、自定义svg
export function findIcon(icon: String, type = "EL", property?: string) { export function findIcon(icon: String, type = "EL", property?: string) {
if (type === "FA") { if (type === "FA") {
return defineComponent({ return defineComponent({
@ -49,6 +53,14 @@ export function findIcon(icon: String, type = "EL", property?: string) {
}, },
template: `<i :class="icon" />` template: `<i :class="icon" />`
}); });
} else if (type === "RI") {
return defineComponent({
name: "RIIcon",
data() {
return { icon: `ri-${icon}` };
},
template: `<i :class="icon" />`
});
} else if (type === "EL") { } else if (type === "EL") {
const components = iconComponents.filter( const components = iconComponents.filter(
component => component.name === icon component => component.name === icon

Loading…
Cancel
Save