mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
refactor(projects): new route guard
This commit is contained in:
@ -10,14 +10,6 @@ import { useSvgIcon } from '@/hooks/common/icon';
|
||||
* @param roles Roles
|
||||
*/
|
||||
export function filterAuthRoutesByRoles(routes: ElegantConstRoute[], roles: string[]) {
|
||||
// in static mode of auth route, the super admin role is defined in front-end
|
||||
const SUPER_ROLE = 'R_SUPER';
|
||||
|
||||
// if the user is super admin, then it is allowed to access all routes
|
||||
if (roles.includes(SUPER_ROLE)) {
|
||||
return routes;
|
||||
}
|
||||
|
||||
return routes.flatMap(route => filterAuthRouteByRoles(route, roles));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user