import Layout from '@/layout'
/**
 * 生成路由
 * @param {Array} routerlist 格式化路由
 * @returns
 */
// export function addRouter(routerlist) {
//   const router = []
//   try {
//     routerlist.forEach(e => {
//       if (e.path && e.menuName && e.component) {
//         let e_new = {
//           path: e.path,
//           name: e.menuName,
//           component: resolve => e.component === 'Layout' ? require([`@/layout`], resolve) : require([`@/views/${e.component}/index`], resolve)
//         }
//         if (e.children) {
//           const children = addRouter(e.children)
//           // 保存权限
//           e_new = { ...e_new, children: children }
//         }
//         if (e.redirect) {
//           e_new = { ...e_new, redirect: e.redirect }
//         }
//         // if (e.generatemenu === 0) {
//         //   e_new = { ...e_new, hidden: true }
//         // }
//         if (e.icon !== '' && e.menuLabel !== '') {
//           e_new = { ...e_new, meta: { title: e.menuLabel, icon: e.icon } }
//         } else if (e.menuLabel !== '' && e.icon === '') {
//           e_new = { ...e_new, meta: { title: e.menuLabel } }
//         }
//         router.push(e_new)
//       }

//     })
//   } catch (error) {
//     console.error(error)
//     return []
//   }
//   return router
// }

/**
 * 前端测试使用，暂时写死
 */
export function addRouter() {

  const asyncRouterMap = [
    {
      path: '/business',
      component: Layout,
      name: 'Business',
      hidden: false,
      meta: {
        title: '业务管理',
        icon: 'yewu'
      },
      redirect: '/culturalRelic',
      children: [{
        path: 'culturalRelic',
        name: 'CulturalRelic',
        component: () => import('@/views/culturalRelic/index'),
        meta: {
          title: '文物管理',
          icon: 'culturalRelic'
        },
      },
      {
        path: 'display',
        name: 'Display',
        component: () => import('@/views/display/index'),
        meta: {
          title: '展览管理',
          icon: 'display'
        }
      },
      // {
      //   path: 'boutique',
      //   name: 'Boutique',
      //   component: () => import('@/views/boutique/index'),
      //   meta: {
      //     title: '精品展管理',
      //     icon: 'boutique'
      //   }
      // },
      {
        path: 'museum',
        name: 'Museum',
        component: () => import('@/views/museum/index'),
        meta: {
          title: '博物馆管理',
          icon: 'museum'
        }
      },
      {
        path: 'virtual',
        name: 'Virtual',
        component: () => import('@/views/virtual/index'),
        meta: {
          title: '虚拟展厅',
          icon: 'virtual'
        }
      },
      {
        path: 'literature',
        name: 'Literature',
        component: () => import('@/views/literature/index'),
        meta: {
          title: '文献管理',
          icon: 'literature'
        }
      },
      {
        path: 'product',
        name: 'Product',
        component: () => import('@/views/product/index'),
        meta: {
          title: '文创产品管理',
          icon: 'product'
        }
      },
      {
        path: 'approval',
        name: 'Approval',
        component: () => import('@/views/approval/index'),
        // redirect: '/crApproval',
        meta: {
          title: '审批管理',
          icon: 'approval'
        },
        children: [
          // {
          //   path: 'crApproval',
          //   name: 'CrApproval',
          //   component: () => import('@/views/approval/culturalRelic.vue'),
          //   meta: {
          //     title: '文物',
          //     icon: 'culturalRelic'
          //   }
          // },
          {
            path: 'displayApproval',  
            name: 'DisplayApproval',
            component: () => import('@/views/approval/display.vue'),
            meta: {
              title: '展览审批',
              icon: 'display'
            }
          }
        ]
      }
      ]
    },
    {
      path: '/system',
      component: Layout,
      name: 'System',
      hidden: false,
      meta: {
        title: '系统管理',
        icon: 'xitong'
      },
      redirect: '/user',
      children: [{
        path: 'user',
        name: 'User',
        component: () => import('@/views/user/index'),
        meta: {
          title: '用户管理',
          icon: 'user2'
        }
      },
      {
        path: 'role',
        name: 'Role',
        component: () => import('@/views/role/index'),
        meta: {
          title: '角色管理',
          icon: 'role'
        }
      },
      {
        path: 'log',
        name: 'Log',
        component: () => import('@/views/log/index'),
        meta: {
          title: '日志管理',
          icon: 'log'
        }
      },
      ]
    },
  ]

  return asyncRouterMap
}