diff --git a/packages/utils/src/helpers/generate-routes-frontend.ts b/packages/utils/src/helpers/generate-routes-frontend.ts index dafc8a7d33a..75acf4956e1 100644 --- a/packages/utils/src/helpers/generate-routes-frontend.ts +++ b/packages/utils/src/helpers/generate-routes-frontend.ts @@ -21,13 +21,22 @@ async function generateRoutesByFrontend( // 如果有禁止访问的页面,将禁止访问的页面替换为403页面 return mapTree(finalRoutes, (route) => { - if (menuHasVisibleWithForbidden(route)) { + if (isForBidden(route, roles)) { route.component = forbiddenComponent; } return route; }); } +/** + * 判断是否禁止访问 + * @param route + * @returns + */ +function isForBidden (route: RouteRecordRaw, roles: string[]) { + return !!route.meta?.authority && !roles.some((role) => route.meta?.authority?.includes(role)); +} + /** * 判断路由是否有权限访问 * @param route