2020-12-09 13:10:48 +08:00

19 lines
438 B
JavaScript

import { hasAccess } from './core';
export function onRouterCreated({ router }) {
router.beforeEach(async (to, from, next) => {
let path;
if (to.matched.length === 1) {
path = to.matched[0].path;
} else {
path = to.path;
}
const canRoute = await hasAccess(path);
if (canRoute) {
next();
} else {
next(false);
}
});
}