From 1bb51569236fd9bcc55dd9f237f51f218956b258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leo=20Caan=20=28=E9=99=88=E6=A0=8B=29?= Date: Sun, 8 Aug 2021 10:15:34 +0800 Subject: [PATCH] fix(route): the whitelist should include basicRoutes (#1048) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(table): recursive updateTableDataRecord 无刷新更新表格数据时,支持递归查找,用于树状数据时。同时新增 findTableDataRecord 函数,用于支持无刷新新增数据到树状表格中 * fix(router): whitelist include basicRoutes 白名单应包含不在菜单上出现的静态路由,否则在动态切换菜单 resetRouter 时会丢失这些,如在usePermission.resume中 * fix: get basicRoutes whitelist bad code --- src/router/index.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/router/index.ts b/src/router/index.ts index 3d9700f7..c3491515 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -2,10 +2,16 @@ import type { RouteRecordRaw } from 'vue-router'; import type { App } from 'vue'; import { createRouter, createWebHashHistory } from 'vue-router'; -import { basicRoutes, LoginRoute } from './routes'; -import { REDIRECT_NAME } from './constant'; +import { basicRoutes } from './routes'; -const WHITE_NAME_LIST = [LoginRoute.name, REDIRECT_NAME]; +// 白名单应该包含基本静态路由 +const WHITE_NAME_LIST: string[] = []; +const getRouteNames = (array: any[]) => + array.forEach((item) => { + WHITE_NAME_LIST.push(item.name); + getRouteNames(item.children || []); + }); +getRouteNames(basicRoutes); // app router export const router = createRouter({ -- GitLab