import { userRolesDict } from "@/utils/user-roles";
import Catalogue from "@/components/ParentView";
export const createAsyncRoutes = (routerList, role) => {
  return routerList.filter(route => {
    route.component && (route.component = componentsFormat(route.component));
    if (route.children && route.children.length > 0) {
      route.children = createAsyncRoutes(route.children, role);
    }
    return route.meta.roles.includes(userRolesDict[role]);
  });
};

// 动态引用
const componentsFormat = (component) => {
  if (component === "catalogue") {
    return Catalogue;
  }
  return () => import(/* webpackChunkName: "[request]" */`@/${component}`);
};