Commit ec7efcf0f0161c8e14168bf69ba27ba36e2a1ac8

Authored by ZhaoBin
Committed by GitHub
1 parent cbcd9098

fix(router): reserving `Redirect` after reset (#126)

After logging out and then logging in, click Refresh to display 404.
Showing 1 changed file with 2 additions and 1 deletions
src/router/index.ts
@@ -7,6 +7,7 @@ import { createGuard } from './guard/'; @@ -7,6 +7,7 @@ import { createGuard } from './guard/';
7 7
8 import { basicRoutes } from './routes/'; 8 import { basicRoutes } from './routes/';
9 import { scrollBehavior } from './scrollBehavior'; 9 import { scrollBehavior } from './scrollBehavior';
  10 +import { REDIRECT_NAME } from './constant';
10 11
11 export const hashRouter = createWebHashHistory(); 12 export const hashRouter = createWebHashHistory();
12 13
@@ -20,7 +21,7 @@ const router = createRouter({ @@ -20,7 +21,7 @@ const router = createRouter({
20 21
21 // reset router 22 // reset router
22 export function resetRouter() { 23 export function resetRouter() {
23 - const resetWhiteNameList = ['Login']; 24 + const resetWhiteNameList = ['Login', REDIRECT_NAME];
24 router.getRoutes().forEach((route) => { 25 router.getRoutes().forEach((route) => {
25 const { name } = route; 26 const { name } = route;
26 if (name && !resetWhiteNameList.includes(name as string)) { 27 if (name && !resetWhiteNameList.includes(name as string)) {