/*
 * @Descripttion: 当前组件信息
 * @version: 1.0.0
 * @Author: 无尘
 * @Date: 2018-10-10 14:44:45
 * @LastEditors: 无尘
 * @LastEditTime: 2020-12-04 16:10:40
 */
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')) {
  /* eslint-disable */
  store.commit(types.LOGIN, window.sessionStorage.getItem('token'));
}
export const constantRouterMap = [
         {
           path: '/',
           name: '/',
           redirect: 'index'
         },
         {
           path: '/login',
           name: '登录',
           component: _import('login', 'index')
         },

         {
           // 审核中心
           path: '/index',
           name: '审核中心',
           redirect: 'index',
           component: _import('module', 'index'),
           children: [
             {
               path: '/index',
               name: '模块',
               component: _import('module', 'home')
             },
             {
               path: '/second',
               name: '限流',
               component: _import('module', 'second')
             },
             {
               path: '/third',
               name: '关系',
               component: _import('module', 'third')
             }
           ]
         },

         {
           path: '/gic-error',
           name: 'gic跳转失败页',
           component: _import('errorPage', 'gic-error')
         },
         {
           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 })
});
