import type { RouteRecordRaw } from 'vue-router';

// 根据权限列表返回过滤后的路由
export const filterAuthHandle = (authList: (string|number)[], routes: RouteRecordRaw[]) => {
  return routes.filter(el => {
    if (el.children?.length) {
      el.children = filterAuthHandle(authList, el.children)
      return true
    } else {
      if (authList.includes(el.meta?.auth as string)) {
        return true
      } else if (!el.meta?.hasOwnProperty('auth')) {
        return true
      }
      return false
    }
  })
}
