/*
 * @Author: WangQiBiao
 * @Date: 2019-09-18 11:31:29
 * @LastEditors: WangQiBiao
 * @LastEditTime: 2019-10-08 16:01:18
 * @Description: 权限菜单
 */
import _import from './_import'
import MainCom from '@/components/main'
/**
 * 格式化权限路由表
 * @param {array} permisList 权限路由表
 */
export const filtersPermisList = (permisList) => {
  return new Promise((resolve, reject) => {
    const newPermisList = permisList.map(item => {
      return {
        path: `/${item.path}`,
        component: MainCom,
        meta: {
          title: item.meta.title,
          icon: item.meta.icon
        },
        children: item.children && item.children.map(child => {
          return {
            path: child.path,
            component: _import(`${item.path}/${child.path}`),
            meta: {
              title: child.meta.title,
              icon: child.meta.icon
            }
          }
        })
      }
    })
    resolve(newPermisList)
  })
}
