import Vue from 'vue'
import Router from 'vue-router'
const _import = require('./_import_' + process.env.NODE_ENV)
// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/** note: submenu only apppear when children.length>=1
*   detail see  https://panjiachen.github.io/vue-element-admin-site/#/router-and-nav?id=sidebar
**/

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    roles: ['admin','editor']     will control the page roles (you can set multiple roles)
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
    noCache: true                if true ,the page will no be cached(default is false)
  }
**/
export const constantRouterMap = [
  { path: '/login', component: _import('login/index'), hidden: true },
  { path: '/authredirect', component: _import('login/authredirect'), hidden: true },
  { path: '/404', component: _import('errorPage/404'), hidden: true },
  { path: '/401', component: _import('errorPage/401'), hidden: true },
  {
    path: '',
    component: Layout,
    redirect: 'dashboard',
    children: [{
      path: 'dashboard',
      component: _import('dashboard/index'),
      name: 'dashboard',
      meta: { title: 'dashboard', icon: 'home', noCache: true }
    }]
  }
]
export default new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

export const asyncRouterMap = [
  // {
  //   path: '/mmadmin',
  //   component: Layout,
  //   redirect: {
  //     name: 'form2'
  //   },
  //   alwaysShow: true,
  //   meta: {
  //     title: 'mmadmin',
  //     icon: 'mm'
  //   },
  //   children: [
  //     { path: 'create-form', component: _import('mmadmin/create'), name: 'mmadmininfo', meta: { title: 'mmadmininfo', roles: ['manager'] }},
  //     { path: 'mmquerystock-form', component: _import('mmadmin/mmquerystock'), name: 'mmquerystock-form', meta: { title: 'mmquerystock', roles: ['consultant'] }},
  //     { path: 'mmquerystock-formm', component: _import('mmadmin/mmquerystockm'), name: 'mmquerystock-formm', meta: { title: 'mmquerystock', roles: ['manager'] }},
  //     { path: 'train-form', hidden: true, component: _import('mmadmin/train'), name: 'train-form', meta: { title: 'mmadmintrain', roles: ['manager'] }},
  //     { path: 'certificate-form', hidden: true, component: _import('mmadmin/certificate'), name: 'certificate-form', meta: { title: 'mmadmincertificate', roles: ['manager'] }},
  //     { path: 'mmadminstock-form', hidden: true, component: _import('mmadmin/mmadminstock'), name: 'mmadminstock-form', meta: { title: 'mmadminstock', roles: ['manager'] }},
  //     { path: 'edit-form', hidden: true, component: _import('mmadmin/edit'), name: 'mmadmininfo-edit', meta: { title: 'mmadmininfoedit', roles: ['manager'] }},
  //     { path: 'mminfoshow', hidden: true, component: _import('mmadmin/mminfoshow'), name: 'mminfoshow', meta: { title: 'mminfoshow' }},
  //     { path: 'resume-admin', hidden: true, component: _import('mmadmin/resumeadmin'), name: 'resume-admin', meta: { title: 'resumeadmin', roles: ['manager'] }}
  //   ]
  // },
  // {
  //   path: '/coupon',
  //   component: Layout,
  //   redirect: {
  //     name: 'coupon'
  //   },
  //   meta: {
  //     title: 'promotion',
  //     icon: 'coupon',
  //     roles: ['manager']
  //   },
  //   children: [
  //     { path: 'coupon_batch', component: _import('coupon/couponbatch'), name: 'couponbatch', meta: { title: 'couponbatch', roles: ['manager'] }},
  //     { path: 'coupon_batch_edit', hidden: true, component: _import('coupon/couponbatchedit'), name: 'couponbatchedit', meta: { title: 'couponbatchedit', icon: 'table', roles: ['manager'] }},
  //     { path: 'coupon_create', component: _import('coupon/couponcreate'), name: 'couponcreate', meta: { title: 'couponcreate', roles: ['manager'] }},
  //     { path: 'coupon_use', component: _import('coupon/couponuse'), name: 'couponuse', meta: { title: 'couponuse', roles: ['manager'] }},
  //     {
  //       path: '/coupon/report',
  //       redirect: 'noredirect',
  //       component: _import('example/table/index'),
  //       name: 'couponreport',
  //       meta: {
  //         title: 'couponreport'
  //       },
  //       children: [
  //         { path: 'report_batch', component: _import('coupon/report/reportbatch'), name: 'couponreportbatch', meta: { title: 'couponreportbatch', roles: ['manager'] }},
  //         { path: 'report_couponlog', component: _import('coupon/report/reportcouponlog'), name: 'couponreportcouponlog', meta: { title: 'couponreportcouponlog', roles: ['manager'] }},
  //         { path: 'report_customercoupon', component: _import('coupon/report/reportcustomercoupon'), name: 'couponreportcustomercoupon', meta: { title: 'couponreportcustomercoupon', roles: ['manager'] }}
  //       ]
  //     }
  //   ]
  // },
  // {
  //   path: '/equipment',
  //   component: Layout,
  //   redirect: {
  //     name: 'equipment'
  //   },
  //   meta: {
  //     title: 'equipment',
  //     icon: 'equipment',
  //     roles: ['manager']
  //   },
  //   children: [
  //     { path: 'c_stock', component: _import('equipment/equipmentstock'), name: 'equipmentstock', meta: { title: 'equipmentstock', roles: ['manager'] }},
  //     { path: 'equipment_edit', hidden: true, component: _import('equipment/equipmentedit'), name: 'equipmentedit', meta: { title: 'equipmentedit', icon: 'table', roles: ['manager'] }},
  //     { path: 'equipment_show', hidden: true, component: _import('equipment/equipmentshow'), name: 'equipmentshow', meta: { title: 'equipmentshow', icon: 'table', roles: ['manager'] }},
  //     { path: 'equipment_hire_add', hidden: true, component: _import('equipment/equipmenthireadd'), name: 'equipmenthireadd', meta: { title: 'equipmenthireadd', icon: 'table', roles: ['manager'] }},
  //     { path: 'equipment_hire_edit', hidden: true, component: _import('equipment/equipmenthireedit'), name: 'equipmenthireedit', meta: { title: 'equipmenthireedit', icon: 'table', roles: ['manager'] }},
  //     { path: 'equipment_hire_eonline', hidden: true, component: _import('equipment/equipmenthireonline'), name: 'equipmenthireonline', meta: { title: 'equipmenthireedit', icon: 'table', roles: ['manager'] }},
  //     { path: 'equipment_hire_show', hidden: true, component: _import('equipment/equipmenthireshow'), name: 'equipmenthireshow', meta: { title: 'equipmenthireshow', icon: 'table', roles: ['manager'] }},
  //     { path: 'equipment_return', hidden: true, component: _import('equipment/equipmentreturn'), name: 'equipmentreturn', meta: { title: 'equipmentreturn', icon: 'table', roles: ['manager'] }},
  //     { path: 'equipment_hire', component: _import('equipment/equipmenthire'), name: 'equipmenthire', meta: { title: 'equipmenthire', roles: ['manager'] }},
  //     { path: 'equipment_report', component: _import('equipment/equipmentreport'), name: 'equipmentreport', meta: { title: 'equipmentreport', roles: ['manager'] }}
  //   ]
  // },
  // {
  //   path: '/booking',
  //   component: Layout,
  //   redirect: {
  //     name: 'booking'
  //   },
  //   alwaysShow: true,
  //   meta: {
  //     title: 'booking',
  //     icon: 'booking',
  //     roles: ['manager']
  //   },
  //   children: [
  //     { path: 'booking', component: _import('booking/booking'), name: 'booking', meta: { title: 'booking', roles: ['manager'] }}
  //   ]
  // },
  // // {
  // //   path: '/order',
  // //   component: Layout,
  // //   redirect: {
  // //     name: 'order'
  // //   },
  // //   alwaysShow: true,
  // //   meta: {
  // //     title: 'order',
  // //     icon: 'order',
  // //     roles: ['manager']
  // //   },
  // //   children: [
  // //     { path: 'order_temp', component: _import('order/ordertemp'), name: 'ordertemp', meta: { title: 'ordertemp', roles: ['manager'] }},
  // //     { path: 'order_temp_edit', hidden: true, component: _import('order/ordertempedit'), name: 'ordertempedit', meta: { title: 'ordertempedit', icon: 'table', roles: ['manager'] }}
  // //   ]
  // // },
  // {
  //   path: '/excel',
  //   component: Layout,
  //   redirect: '/excel/export-excel',
  //   name: 'excel4',
  //   alwaysShow: true,
  //   meta: {
  //     title: 'useradmin',
  //     icon: 'user'
  //   },
  //   children: [
  //     { path: 'password_modify', component: _import('user/passwordmodify'), name: 'passwordmodify', meta: { title: 'passwordmodify' }},
  //     { path: 'tinymce', component: _import('components-demo/commingsoon'), name: 'tinymce-demo1', meta: { title: 'user', roles: ['manager'] }},
  //     { path: 'markdown', component: _import('components-demo/commingsoon'), name: 'markdown-demo2', meta: { title: 'authority', roles: ['manager'] }},
  //     { path: 'markdown-from', component: _import('components-demo/commingsoon'), name: 'markdown-demo3', meta: { title: 'framework', roles: ['manager'] }}
  //   ]
  // },
  // { path: '*', redirect: '/404', hidden: true }
]
