vben
authored
5 years ago
1
2
import type { Router } from 'vue-router';
import { appStore } from '/@/store/modules/app';
Vben
authored
4 years ago
3
4
5
import { tabStore } from '/@/store/modules/tab';
import { userStore } from '/@/store/modules/user';
import { permissionStore } from '/@/store/modules/permission';
vben
authored
5 years ago
6
import { PageEnum } from '/@/enums/pageEnum';
Vben
authored
4 years ago
7
import { removeTabChangeListener } from '/@/logics/mitt/routeChange';
vben
authored
5 years ago
8
vben
authored
5 years ago
9
export function createStateGuard(router: Router) {
vben
authored
5 years ago
10
11
12
13
router.afterEach((to) => {
// Just enter the login page and clear the authentication information
if (to.path === PageEnum.BASE_LOGIN) {
appStore.resumeAllState();
Vben
authored
4 years ago
14
15
16
permissionStore.commitResetState();
tabStore.commitResetState();
userStore.commitResetState();
vben
authored
5 years ago
17
18
19
20
removeTabChangeListener();
}
});
}