routing permissions
This commit is contained in:
parent
1d2e113c4b
commit
8033038c2e
2 changed files with 6 additions and 4 deletions
|
@ -7,15 +7,15 @@ export async function abilityAndNavUpdate(to: any, from: any, next: any) {
|
||||||
const ability = useAbilityStore();
|
const ability = useAbilityStore();
|
||||||
const navigation = useNavigationStore();
|
const navigation = useNavigationStore();
|
||||||
|
|
||||||
|
let admin = to.meta.admin || false;
|
||||||
let type = to.meta.type;
|
let type = to.meta.type;
|
||||||
let section = to.meta.section;
|
let section = to.meta.section;
|
||||||
let module = to.meta.module;
|
let module = to.meta.module;
|
||||||
|
|
||||||
navigation.activeNavigation = to.name.split("-")[1];
|
if ((admin && ability.isAdmin()) || ability.can(type, section, module)) {
|
||||||
navigation.activeLink = to.name.split("-")[2];
|
|
||||||
|
|
||||||
if (ability.can(type, section, module)) {
|
|
||||||
NProgress.done();
|
NProgress.done();
|
||||||
|
navigation.activeNavigation = to.name.split("-")[1];
|
||||||
|
navigation.activeLink = to.name.split("-")[2];
|
||||||
next();
|
next();
|
||||||
} else {
|
} else {
|
||||||
NProgress.done();
|
NProgress.done();
|
||||||
|
|
|
@ -665,6 +665,8 @@ const router = createRouter({
|
||||||
path: "version",
|
path: "version",
|
||||||
name: "admin-user-version",
|
name: "admin-user-version",
|
||||||
component: () => import("@/views/admin/management/version/VersionDisplay.vue"),
|
component: () => import("@/views/admin/management/version/VersionDisplay.vue"),
|
||||||
|
meta: { admin: true },
|
||||||
|
beforeEnter: [abilityAndNavUpdate],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue