mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-25 16:16:20 +08:00
feat: add demo for modify menu badge data
This commit is contained in:
@@ -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;
|
||||
},
|
||||
|
Reference in New Issue
Block a user