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 OrderData from '@/views/OrderData/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 WorkPlanData from '@/views/WorkPlanData/index.vue'
import MaterialData from '@/views/MaterialData/index.vue'
import PressureSensor from '@/views/PressureSensor/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: '/OrderData',
    name: 'OrderData',
    component: OrderData
  },
  {
    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: '/WorkPlanData',
    name: 'WorkPlanData',
    component: WorkPlanData
  },
  {
    path: '/MaterialData',
    name: 'MaterialData',
    component: MaterialData
  },
  {
    path: '/PressureSensor',
    name: 'PressureSensor',
    component: PressureSensor
  }
  ]
}
]
export default new Router({
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRouterMap
})
