refactor(projects): new route guard

This commit is contained in:
Soybean
2024-03-25 02:42:50 +08:00
parent c11d56da29
commit 37d20b8e0d
12 changed files with 316 additions and 214 deletions

View File

@ -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));
}