Commit 1bb51569236fd9bcc55dd9f237f51f218956b258
Committed by
GitHub
1 parent
62f84687
fix(route): the whitelist should include basicRoutes (#1048)
* fix(table): recursive updateTableDataRecord 无刷新更新表格数据时,支持递归查找,用于树状数据时。同时新增 findTableDataRecord 函数,用于支持无刷新新增数据到树状表格中 * fix(router): whitelist include basicRoutes 白名单应包含不在菜单上出现的静态路由,否则在动态切换菜单 resetRouter 时会丢失这些,如在usePermission.resume中 * fix: get basicRoutes whitelist bad code
Showing
1 changed file
with
9 additions
and
3 deletions
src/router/index.ts
@@ -2,10 +2,16 @@ import type { RouteRecordRaw } from 'vue-router'; | @@ -2,10 +2,16 @@ import type { RouteRecordRaw } from 'vue-router'; | ||
2 | import type { App } from 'vue'; | 2 | import type { App } from 'vue'; |
3 | 3 | ||
4 | import { createRouter, createWebHashHistory } from 'vue-router'; | 4 | import { createRouter, createWebHashHistory } from 'vue-router'; |
5 | -import { basicRoutes, LoginRoute } from './routes'; | ||
6 | -import { REDIRECT_NAME } from './constant'; | 5 | +import { basicRoutes } from './routes'; |
7 | 6 | ||
8 | -const WHITE_NAME_LIST = [LoginRoute.name, REDIRECT_NAME]; | 7 | +// 白名单应该包含基本静态路由 |
8 | +const WHITE_NAME_LIST: string[] = []; | ||
9 | +const getRouteNames = (array: any[]) => | ||
10 | + array.forEach((item) => { | ||
11 | + WHITE_NAME_LIST.push(item.name); | ||
12 | + getRouteNames(item.children || []); | ||
13 | + }); | ||
14 | +getRouteNames(basicRoutes); | ||
9 | 15 | ||
10 | // app router | 16 | // app router |
11 | export const router = createRouter({ | 17 | export const router = createRouter({ |