From d5fc6aeb893a4d571487bb3794d97980f8d16382 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=8E=E7=94=9F=E7=A0=94=E7=A9=B6=E5=91=98?= <442691556@qq.com> Date: Tue, 18 Jun 2024 14:00:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=9C=A8=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E9=A1=B5=E9=9D=A2=E4=B8=AD=EF=BC=8C=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E5=92=8C=E7=BC=96=E8=BE=91=E8=8F=9C=E5=8D=95=E6=9D=A1?= =?UTF-8?q?=E7=9B=AE=E5=BC=B9=E7=AA=97=E4=B8=AD=E7=9A=84awe=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=E5=88=97=E8=A1=A8=E7=94=9F=E6=88=90=E7=9A=84js?= =?UTF-8?q?=E7=AE=97=E6=B3=95=EF=BC=8C=E4=BD=BF=E7=94=A8=E6=88=B7=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E9=80=89=E6=8B=A9=E6=89=80=E6=9C=89=E5=90=88=E6=B3=95?= =?UTF-8?q?=E7=9A=84awe=E5=9B=BE=E6=A0=87=E3=80=82=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=89=8D=E5=87=A1=E6=98=AF=20=E4=B8=80=E4=B8=AAcalss=E4=B8=AD?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E5=A4=9A=E4=B8=AA=E5=9B=BE=E6=A0=87=E7=9A=84?= =?UTF-8?q?=E6=9D=A1=E7=9B=AE=E5=9D=87=E6=97=A0=E6=B3=95=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ClientApp/src/utils/getStyleSheets.ts | 46 ++++++++++--------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/demo/WalkingTec.Mvvm.Vue3Demo/ClientApp/src/utils/getStyleSheets.ts b/demo/WalkingTec.Mvvm.Vue3Demo/ClientApp/src/utils/getStyleSheets.ts index 8a2d45992..6a5c02b0b 100644 --- a/demo/WalkingTec.Mvvm.Vue3Demo/ClientApp/src/utils/getStyleSheets.ts +++ b/demo/WalkingTec.Mvvm.Vue3Demo/ClientApp/src/utils/getStyleSheets.ts @@ -40,29 +40,33 @@ const getElementPlusIconfont = () => { // 初始化获取 css 样式,这里使用 fontawesome 的图标 const getAwesomeIconfont = () => { - return new Promise((resolve, reject) => { - nextTick(() => { - const styles: any = document.styleSheets; - let sheetsIconList = []; + return new Promise((resolve, reject) => { + nextTick(() => { + const styles: any = document.styleSheets; + let sheetsIconList = []; for (let i = 0; i < styles.length; i++) { for (let j = 0; j < styles[i].cssRules.length; j++) { - if ( - styles[i].cssRules[j].selectorText && - styles[i].cssRules[j].selectorText.indexOf('.fa-') === 0 && - styles[i].cssRules[j].selectorText.indexOf(',') === -1 - ) { - if (/::before/.test(styles[i].cssRules[j].selectorText)) { - sheetsIconList.push( - `${styles[i].cssRules[j].selectorText.substring(1, styles[i].cssRules[j].selectorText.length).replace(/\:\:before/gi, '')}` - ); - } - } - } - } - if (sheetsIconList.length > 0) resolve(sheetsIconList.reverse()); - else reject('未获取到值,请刷新重试'); - }); - }); + let selectorText = styles[i].cssRules[j].selectorText + if ( + selectorText && + selectorText.includes('.fa-') + ) { + let newSelectorTextList: [string] = selectorText.split(", ") + for (let k = 0; k < newSelectorTextList.length; k++) { + const element = newSelectorTextList[k]; + if (/::before/.test(element)) { + sheetsIconList.push( + `${element.substring(1, element.length).replace(/\:\:before/gi, '')}` + ); + } + } + } + } + } + if (sheetsIconList.length > 0) resolve(sheetsIconList.reverse()); + else reject('未获取到值,请刷新重试'); + }); + }); }; /**