fix(mitt): logout and clear the mitt
| | |
| | | "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", |
| | |
| | | "@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", |
| | |
| | | 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)) { |
| | |
| | | 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; |
| | | |
| | |
| | | const nextData = to.path === redirect ? { ...to, replace: true } : { path: redirect }; |
| | | 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(); |
| | | } |
| | | }); |
| | | } |
New file |
| | |
| | | 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(); |
| | | } |
| | | }); |
| | | } |