Navigation Guards
Zova provides a module home-router
. We can add navigation guards to this module, such as judging user authentication status, jumping on the login page, and so on
onRouterGuards
The module home-router
provides a LocalRouter
bean, just add custom logic directly in the onRouterGuards
method as well
src/suite/a-home/modules/home-router/src/bean/local.router.ts
typescript
export class LocalRouter {
protected onRouterGuards(router: BeanRouter) {
router.beforeEach(async to => {
console.log(to);
console.log(to.meta.requiresAuth);
});
}
}
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
- For specific usage of
router
, see: Vue Router: Navigation Guards
$router
Zova injects the $router
object into the BeanBase
base class, so that the Vue router object can be obtained through this.$router
in any bean instance