import Vue from 'vue'
import Router from 'vue-router'
import layout from '@/views/layout/index.vue'
import Login from '@/views/Login/index.vue'
import OperationGuide from '@/views/OperationGuide/index.vue'
import OrderCompletion from '@/views/OrderCompletion/index.vue'
import QualityInquiry from '@/views/QualityInquiry/index.vue'
import Andon from '@/views/Andon/index.vue'
import DeviceManagement from '@/views/EquipmentMaintenance/index.vue'
import MaterialPull from '@/views/MaterialPull/index.vue'
import RepairManagement from '@/views/RepairManagement/index.vue'
import CheckTodayPlan from '@/views/CheckTodayPlan/index.vue'
import BarCodeCheck from '@/views/BarCodeCheck/index.vue'
import AccessoryCompare from '@/views/AccessoryCompare/index.vue'
import BindRecord from '@/views/BindRecord/index.vue'

Vue.use(Router)
const originalPush = Router.prototype.push

Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

export const constantRouterMap = [{
  path: '/',
  name: 'Login',
  component: Login
},
{
  path: '/layout',
  name: 'layout',
  component: layout,
  children: [{
    path: '/OperationGuide',
    name: 'OperationGuide',
    component: OperationGuide
    // meta: {
    //   keepAlive: true
    // }
  },
  {
    path: '/OperationGuidePdf',
    name: 'OperationGuidePdf',
    component: () => import('@/views/OperationGuidePdf/index.vue')
  },
  {
    path: '/OrderCompletion',
    name: 'OrderCompletion',
    component: OrderCompletion
  },
  {
    path: '/QualityInquiry',
    name: 'QualityInquiry',
    component: QualityInquiry
  },
  {
    path: '/Andon',
    name: 'Andon',
    component: Andon
  },
  {
    path: '/DeviceManagement',
    name: 'DeviceManagement',
    component: DeviceManagement
  },
  {
    path: '/MaterialPull',
    name: 'MaterialPull',
    component: MaterialPull
  },
  {
    path: '/RepairManagement',
    name: 'RepairManagement',
    component: RepairManagement
  },
  {
    path: '/CheckTodayPlan',
    name: 'CheckTodayPlan',
    component: CheckTodayPlan
  },
  {
    path: '/BarCodeCheck',
    name: 'BarCodeCheck',
    component: BarCodeCheck
  },
  {
    path: '/AccessoryCompare',
    name: 'AccessoryCompare',
    component: AccessoryCompare
  },
  {
    path: '/BindRecord',
    name: 'BindRecord',
    component: BindRecord
  }
  ]
}
]
export default new Router({
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRouterMap
})
