mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2026-01-15 08:47:03 +08:00
19 lines
438 B
JavaScript
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);
|
|
}
|
|
});
|
|
}
|