Commit 0aeec5e9 authored by vben's avatar vben

fix(mitt): logout and clear the mitt

parent b9d53a71
......@@ -181,6 +181,7 @@ export function useDataSource(
const resultTotal: number = isArrayResult ? 0 : get(res, totalField);
// 假如数据变少,导致总页数变少并小于当前选中页码,通过getPaginationRef获取到的页码是不正确的,需获取正确的页码再次执行
if (resultTotal) {
const currentTotalPage = Math.ceil(resultTotal / pageSize);
if (current > currentTotalPage) {
setPagination({
......@@ -188,6 +189,7 @@ export function useDataSource(
});
fetch(opt);
}
}
if (afterFetch && isFunction(afterFetch)) {
resultItems = afterFetch(resultItems) || resultItems;
......
......@@ -25,3 +25,7 @@ export function listenerLastChangeTab(
mitt.on(key, callback);
immediate && callback(lastChangeTab);
}
export function removeTabChangeListener() {
mitt.clear();
}
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();
}
});
}
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();
}
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment