module.exports = {
  /**
   * @param {*} asyncRoutes 需要筛选的路由表
   * @param {*} resources auth返回的平铺资源列表
   * @returns 返回需要筛选路由存在于平铺资源列表里的路由
   */
  filterAsyncRoutes(asyncRoutes, resources) {
    const filterRoutes = [];
    asyncRoutes.forEach((asy) => {
      if (resources.find((res) => res.name === asy.name)) {
        if (asy.children) {
          asy.children = this.filterAsyncRoutes(asy.children, resources);
        }
        filterRoutes.push(asy);
      }
    });
    return filterRoutes;
  },
};
