import Vue from 'vue'
import Router from 'vue-router'

import routerBefore from '@/config/routerBefore.js'
// 主要
// import main from '@/components/main.vue'
// 页面示例
// import mypage from '../components/myPage.vue'
Vue.use(Router)
const constantRouterMap = [{
  path: '/',
  name: 'main',
  component: resolve => require(['@/components/main.vue'], resolve),
  redirect: {
    name: 'customersManagement'
  },
  children: [
    {
      path: 'customersManagement',
      name: 'customersManagement',
      component: resolve => require(['../components/customersManagement/customersManagement.vue'], resolve)
    },
    {
      path: 'merchantsEvaluation',
      name: 'merchantsEvaluation',
      component: resolve => require(['../components/merchantsEvaluation/merchantsEvaluation.vue'], resolve)
    },
    {
      path: 'customersInfoManagement',
      name: 'customersInfoManagement',
      component: resolve => require(['../components/customersInfoManagement/customersInfoManagement.vue'], resolve)
    },
    {
      path: 'customersComplaintManagement',
      name: 'customersComplaintManagement',
      component: resolve => require(['../components/customersComplaintManagement/customersComplaintManagement.vue'], resolve)
    },
    { // 样品抽查
      path: 'sampleRandomCheck',
      name: 'sampleRandomCheck',
      component: resolve => require(['../components/sampleRandomCheck/sampleRandomCheck.vue'], resolve)
    },
    {
      path: 'qualityControlManagement',
      name: 'qualityControlManagement',
      component: resolve => require(['../components/qualityControlManagement/qualityControlManagement.vue'], resolve)
    },
    {
      path: 'temperatureManagement',
      name: 'temperatureManagement',
      component: resolve => require(['../components/temperatureManagement/temperatureManagement.vue'], resolve)
    }
  ]
}];
const router = new Router({
  routes: constantRouterMap
})

//  before
routerBefore(router, constantRouterMap);

export default router;
//  constantRouterMap
export const routes = constantRouterMap;
// export default new Router({
//   routes: [
//     {
//       path: '/',
//       name: 'main',
//       component: main,
//       redirect: {name: 'mypage'},
//       children: [
//         {path: 'mypage', name: 'mypage', component: mypage}
//         ]
//     }
//   ]
// })
