routing inside url

This commit is contained in:
Julian Krauser 2024-09-01 19:19:48 +02:00
parent 2d0fb30558
commit 6247c385c3
15 changed files with 278 additions and 203 deletions

24
src/router/adminGuard.ts Normal file
View file

@ -0,0 +1,24 @@
import NProgress from "nprogress";
import { useAbilityStore } from "../stores/ability";
import { useNavigationStore } from "../stores/admin/navigation";
export async function abilityAndNavUpdate(to: any, from: any, next: any) {
NProgress.start();
const ability = useAbilityStore();
const navigation = useNavigationStore();
let type = to.meta.type;
let section = to.meta.section;
let module = to.meta.module;
navigation.activeNavigation = to.name.split("-")[1];
navigation.activeLink = to.name.split("-")[2];
if (ability.can(type, section, module)) {
NProgress.done();
next();
} else {
NProgress.done();
next(false);
}
}