---初始化后台管理web页面项目
This commit is contained in:
24
src/router/guard/stateGuard.ts
Normal file
24
src/router/guard/stateGuard.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import type { Router } from 'vue-router';
|
||||
import { useAppStore } from '/@/store/modules/app';
|
||||
import { useMultipleTabStore } from '/@/store/modules/multipleTab';
|
||||
import { useUserStore } from '/@/store/modules/user';
|
||||
import { usePermissionStore } from '/@/store/modules/permission';
|
||||
import { PageEnum } from '/@/enums/pageEnum';
|
||||
import { removeTabChangeListener } from '/@/logics/mitt/routeChange';
|
||||
|
||||
export function createStateGuard(router: Router) {
|
||||
router.afterEach((to) => {
|
||||
// Just enter the login page and clear the authentication information
|
||||
if (to.path === PageEnum.BASE_LOGIN) {
|
||||
const tabStore = useMultipleTabStore();
|
||||
const userStore = useUserStore();
|
||||
const appStore = useAppStore();
|
||||
const permissionStore = usePermissionStore();
|
||||
appStore.resetAllState();
|
||||
permissionStore.resetState();
|
||||
tabStore.resetState();
|
||||
userStore.resetState();
|
||||
removeTabChangeListener();
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user