mirror of
https://github.com/vbenjs/vben-admin-thin-next.git
synced 2025-02-03 02:18:40 +08:00
fix(mitt): logout and clear the mitt
This commit is contained in:
parent
b9d53a7133
commit
0aeec5e9d7
@ -45,7 +45,7 @@
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^11.0.0",
|
||||
"@commitlint/config-conventional": "^11.0.0",
|
||||
"@iconify/json": "^1.1.285",
|
||||
"@iconify/json": "^1.1.286",
|
||||
"@ls-lint/ls-lint": "^1.9.2",
|
||||
"@purge-icons/generated": "^0.5.1",
|
||||
"@types/echarts": "^4.9.3",
|
||||
@ -62,7 +62,7 @@
|
||||
"@types/zxcvbn": "^4.4.0",
|
||||
"@typescript-eslint/eslint-plugin": "^4.13.0",
|
||||
"@typescript-eslint/parser": "^4.13.0",
|
||||
"@vitejs/plugin-legacy": "^1.2.0",
|
||||
"@vitejs/plugin-legacy": "^1.2.1",
|
||||
"@vitejs/plugin-vue": "^1.0.5",
|
||||
"@vitejs/plugin-vue-jsx": "^1.0.2",
|
||||
"@vue/compiler-sfc": "^3.0.5",
|
||||
|
@ -181,12 +181,14 @@ export function useDataSource(
|
||||
const resultTotal: number = isArrayResult ? 0 : get(res, totalField);
|
||||
|
||||
// 假如数据变少,导致总页数变少并小于当前选中页码,通过getPaginationRef获取到的页码是不正确的,需获取正确的页码再次执行
|
||||
const currentTotalPage = Math.ceil(resultTotal / pageSize);
|
||||
if (current > currentTotalPage) {
|
||||
setPagination({
|
||||
current: currentTotalPage,
|
||||
});
|
||||
fetch(opt);
|
||||
if (resultTotal) {
|
||||
const currentTotalPage = Math.ceil(resultTotal / pageSize);
|
||||
if (current > currentTotalPage) {
|
||||
setPagination({
|
||||
current: currentTotalPage,
|
||||
});
|
||||
fetch(opt);
|
||||
}
|
||||
}
|
||||
|
||||
if (afterFetch && isFunction(afterFetch)) {
|
||||
|
@ -25,3 +25,7 @@ export function listenerLastChangeTab(
|
||||
mitt.on(key, callback);
|
||||
immediate && callback(lastChangeTab);
|
||||
}
|
||||
|
||||
export function removeTabChangeListener() {
|
||||
mitt.clear();
|
||||
}
|
||||
|
@ -1,13 +1,11 @@
|
||||
import type { Router, RouteRecordRaw } from 'vue-router';
|
||||
|
||||
import { appStore } from '/@/store/modules/app';
|
||||
import { permissionStore } from '/@/store/modules/permission';
|
||||
|
||||
import { PageEnum } from '/@/enums/pageEnum';
|
||||
import { getToken } from '/@/utils/auth';
|
||||
|
||||
import { PAGE_NOT_FOUND_ROUTE } from '/@/router/constant';
|
||||
// import { RootRoute } from '../routes/index';
|
||||
|
||||
const LOGIN_PATH = PageEnum.BASE_LOGIN;
|
||||
|
||||
@ -69,11 +67,4 @@ export function createPermissionGuard(router: Router) {
|
||||
permissionStore.commitDynamicAddedRouteState(true);
|
||||
next(nextData);
|
||||
});
|
||||
|
||||
router.afterEach((to) => {
|
||||
// Just enter the login page and clear the authentication information
|
||||
if (to.path === LOGIN_PATH) {
|
||||
appStore.resumeAllState();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
14
src/router/guard/stateGuard.ts
Normal file
14
src/router/guard/stateGuard.ts
Normal file
@ -0,0 +1,14 @@
|
||||
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 createHttpGuard(router: Router) {
|
||||
router.afterEach((to) => {
|
||||
// Just enter the login page and clear the authentication information
|
||||
if (to.path === PageEnum.BASE_LOGIN) {
|
||||
appStore.resumeAllState();
|
||||
removeTabChangeListener();
|
||||
}
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user