From f83aba02d8f6ed49fcbccb58c428daa45e7e9352 Mon Sep 17 00:00:00 2001 From: xiaoxian521 <1923740402@qq.com> Date: Fri, 17 Dec 2021 15:18:48 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=90=8C=E6=AD=A5=E5=AE=8C=E6=95=B4?= =?UTF-8?q?=E7=89=88=E5=88=86=E6=94=AF=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ReIcon/index.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/ReIcon/index.ts b/src/components/ReIcon/index.ts index 0d2b770..9861527 100644 --- a/src/components/ReIcon/index.ts +++ b/src/components/ReIcon/index.ts @@ -13,6 +13,8 @@ export function findIconReg(icon: string) { const faReg = /^FA-/; // iconfont const iFReg = /^IF-/; + // remixicon + const riReg = /^RI-/; // typeof icon === "function" 属于SVG if (faReg.test(icon)) { const text = icon.split(faReg)[1]; @@ -25,12 +27,14 @@ export function findIconReg(icon: string) { return findIcon(icon.split(iFReg)[1], "IF"); } else if (typeof icon === "function") { return findIcon(icon, "SVG"); + } else if (riReg.test(icon)) { + return findIcon(icon.split(riReg)[1], "RI"); } else { 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) { if (type === "FA") { return defineComponent({ @@ -49,6 +53,14 @@ export function findIcon(icon: String, type = "EL", property?: string) { }, template: `` }); + } else if (type === "RI") { + return defineComponent({ + name: "RIIcon", + data() { + return { icon: `ri-${icon}` }; + }, + template: `` + }); } else if (type === "EL") { const components = iconComponents.filter( component => component.name === icon