This commit is contained in:
dap
2024-12-17 08:01:02 +08:00
101 changed files with 853 additions and 193 deletions

View File

@@ -41,6 +41,25 @@ interface AccessState {
*/
export const useAccessStore = defineStore('core-access', {
actions: {
getMenuByPath(path: string) {
function findMenu(
menus: MenuRecordRaw[],
path: string,
): MenuRecordRaw | undefined {
for (const menu of menus) {
if (menu.path === path) {
return menu;
}
if (menu.children) {
const matched = findMenu(menu.children, path);
if (matched) {
return matched;
}
}
}
}
return findMenu(this.accessMenus, path);
},
setAccessCodes(codes: string[]) {
this.accessCodes = codes;
},