import Vue from 'vue'
import Router from 'vue-router'
import _import from './_import.js'
Vue.use(Router);

// const error403 = (r) => {
//   import('views/errorPage/403.vue').then((module) => {
//     r(module)
//   })
// };
// const error404 = (r) => {
//   import('views/errorPage/404.vue').then((module) => {
//     r(module)
//   })
// };
// const error500 = (r) => {
//   import('views/errorPage/500.vue').then((module) => {
//     r(module)
//   })
// };
const errorPage = (r) => {
  import('views/errorPage/index.vue').then((module) => {
    r(module)
  })
};
// 页面刷新时，重新赋值token
if (window.sessionStorage.getItem('token')) {
  store.commit(types.LOGIN, window.sessionStorage.getItem('token'))
}
export const constantRouterMap = [
  {
    path: '/index',
    name: 'index',
    component: _import('index','index'),
  },

  {
    path: '/staffRecordsTemplate',
    name: '员工档案',
    component: _import('contacts','staffRecordsTemplate')
  },
  {
    path: '/403',
    name: '无权访问',
    component: errorPage
  },
  {
    path: '/404',
    name: 'error404',
    component: errorPage
  },
  {
    path: '/500',
    name: 'error500',
    component: errorPage
  },
  { path: '*', redirect: '/404', hidden: true },
];
export default new Router({
  // mode:'history',
  routes: constantRouterMap,
  scrollBehavior: () => ({ y: 0 }),
})
