Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

优化在菜单管理页面中,创建和编辑菜单条目弹窗中的awe图标列表生成的js算法 #641

Open
wants to merge 1 commit into
base: dotnet8
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 25 additions & 21 deletions demo/WalkingTec.Mvvm.Vue3Demo/ClientApp/src/utils/getStyleSheets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('未获取到值,请刷新重试');
});
});
};

/**
Expand Down