/*
 * @Descripttion: 当前组件信息
 * @version: 1.0.0
 * @Author: 无尘
 * @Date: 2019-07-22 17:33:54
 * @LastEditors: 无尘
 * @LastEditTime: 2019-07-22 17:33:54
 */
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);
  });
};

export const constantRouterMap = [
  {
    path: '/',
    name: '/',
    redirect: 'login'
  },
  {
    path: '/login',
    name: '登录',
    component: _import('login', 'index')
  },
  {
    // api 网关
    path: '/index',
    name: '概览',
    redirect: 'overview',
    component: _import('index', 'index'),
    children: [
      {
        path: '/overview',
        name: '概览',
        component: _import('index', 'overview')
      },
      {
        path: '/apiProgram',
        name: '项目列表',
        component: _import('index', 'apiProgram')
      },
      {
        path: '/apiProgramGroup',
        name: '分组列表',
        component: _import('index', 'apiProgramGroup')
      },
      {
        path: '/apiList',
        name: 'API列表',
        component: _import('index', 'apiList')
      },
      {
        path: '/groupApiList',
        name: '项目分组API列表',
        component: _import('index', 'groupApiList')
      },
      {
        path: '/createApi',
        name: '创建API',
        component: _import('index', 'createApi')
      },
      {
        path: '/apiListManage',
        name: 'API列表管理',
        component: _import('index', 'apiListManage')
      },
      {
        path: '/apiListManageShow',
        name: 'API列表管理查看',
        component: _import('index', 'apiListManageShow')
      },
      {
        path: '/envManage',
        name: '环境管理',
        component: _import('index', 'envManage')
      },
      {
        path: '/createEnvSet',
        name: '新建配置',
        component: _import('index', 'createEnvSet')
      },
      {
        path: '/releaseRecords',
        name: '发布记录',
        component: _import('index', 'releaseRecords')
      },
      {
        path: '/pluginManage',
        name: '插件管理',
        component: _import('index', 'pluginManage')
      },
      {
        path: '/plugAhsh',
        name: '插件管理',
        component: _import('index', 'plugAhsh')
      },
      {
        path: '/plugPlatform',
        name: '插件管理',
        component: _import('index', 'plugPlatform')
      },
      {
        path: '/errorCode',
        name: '错误码',
        component: _import('index', 'errorCode')
      }
    ]
  },

  {
    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 })
});
