vue-vben-admin/src/router/guard/stateGuard.ts

15 lines
483 B
TypeScript
Raw Normal View History

2021-01-15 00:10:06 +08:00
import type { Router } from 'vue-router';
import { appStore } from '/@/store/modules/app';
import { PageEnum } from '/@/enums/pageEnum';
import { removeTabChangeListener } from '/@/logics/mitt/tabChange';
export function createStateGuard(router: Router) {
2021-01-15 00:10:06 +08:00
router.afterEach((to) => {
// Just enter the login page and clear the authentication information
if (to.path === PageEnum.BASE_LOGIN) {
appStore.resumeAllState();
removeTabChangeListener();
}
});
}