feat: add demo for modify menu badge data
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
export { default as MenuBadge } from './components/menu-badge.vue';
|
||||
export * from './components/normal-menu';
|
||||
export { default as Menu } from './menu.vue';
|
||||
export type * from './types';
|
||||
|
@@ -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