import Vue          from 'vue';
import Router       from 'vue-router';
import { getAuth }  from '@/utils/auth';
import { getGuide } from '@/utils/guide';
import {
    getTenantCode, getSystemConfig,
    getUserIcon, shitiStatusControl,
    saveHistoryPaths,
}                   from '@/utils/common';

Vue.use(Router);
const originalPush = Router.prototype.push
Router.prototype.push = function push (location) {
    return originalPush.call(this, location).catch(err => err)
};
const router = new Router({
                              mode:   'history',
                              base:   process.env.BASE_URL,
                              routes: [
                                  {
                                      path:     '/',
                                      redirect: '/login',
                                  },
                                  {
                                      name:      'Login',
                                      path:      '/login',
                                      component: () => {
                                          return import(/* webpackChunkName: "Login" */ './views/management/Login/index.vue');
                                      },
                                  },
                                  {
                                      path:'/c/',
                                      component: () => import(/* webpackChunkName: "Cframe" */ './components/client/common/Cframe.vue'),
                                      children:  [
                                          {
                                              name:      'index',
                                              path:      'index',
                                              component: () => {
                                                  return import(/* webpackChunkName: "index" */ './views/client/Index.vue');
                                              },
                                          },
                                          {
                                              name:      'examsystem',
                                              path:      'examsystem',
                                              meta:      {
                                                  parentPath: 'croot',
                                                  breadcrumb: {
                                                      display: '考试平台',
                                                  },
                                              },
                                              component: () => {
                                                  return import(/* webpackChunkName: "examsystem" */ './views/client/examsystem.vue');
                                              },
                                          },
                                          {
                                              name:      'trainsystem',
                                              path:      'trainsystem',
                                              meta:      {
                                                  parentPath: 'croot',
                                                  breadcrumb: {
                                                      display: '培训平台',
                                                  },
                                              },
                                              component: () => {
                                                  return import(/* webpackChunkName: "trainsystem" */ './views/client/trainsystem.vue');
                                              },
                                          },
                                          {
                                              name:      'courseDev',
                                              path:      'courseDev',
                                              meta:      {
                                                  parentPath: 'croot',
                                                  breadcrumb: {
                                                      display: '课程列表',
                                                  },
                                              },
                                              component: () => {
                                                  return import(/* webpackChunkName: "incourseDevdex" */ './views/client/CourseDev.vue');
                                              },
                                          },
                                          {
                                              name:      'newsInfor',
                                              path:      'newsInfor',
                                              meta:      {
                                                  parentPath: 'croot',
                                                  breadcrumb: {
                                                      display: '新闻资讯',
                                                  },
                                              },
                                              component: () => {
                                                  return import(/* webpackChunkName: "newsInfor" */ './views/client/newsInfor.vue');
                                              },
                                          },
                                          {
                                              name:      'helpCenter',
                                              path:      'helpCenter',
                                              meta:      {
                                                  parentPath: 'croot',
                                                  breadcrumb: {
                                                      display: '帮助中心',
                                                  },
                                              },
                                              component: () => {
                                                  return import(/* webpackChunkName: "helpCenter" */ './views/client/helpCenter.vue');
                                              },
                                          },
                                          {
                                              name:      'aboutUs',
                                              path:      'aboutUs',
                                              meta:      {
                                                  parentPath: 'croot',
                                                  breadcrumb: {
                                                      display: '关于我们',
                                                  },
                                              },
                                              component: () => {
                                                  return import(/* webpackChunkName: "aboutUs" */ './views/client/aboutUs.vue');
                                              },
                                          },
                                          {
                                              path: 'newsInforDetails',
                                              name: 'newsInforDetails',
                                              meta:      {
                                                  parentPath: 'croot',
                                                  breadcrumb: {
                                                      display: '行业详情',
                                                  },
                                              },
                                              component: () => {
                                                  return import(/* webpackChunkName: "newsInforDetails" */ './views/client/newsInforDetails.vue');
                                              },
                                          },
                                      ],

                                  },

                                  {
                                      name:      'admin',
                                      path:      '/admin',
                                      meta: {
                                          icon: "el-icon-platform-eleme",
                                          title: "页面管理"
                                      },
                                      isAdminMenu: true,
                                      component: () => {
                                          return import(/* webpackChunkName: "admin" */ './views/management/Home/index.vue');
                                      },
                                      children:  [
                                          {
                                              path: '/newsClassify',
                                              name: 'newsClassify',
                                              meta: {
                                                  icon: "",
                                                  title: "新闻分类"
                                              },
                                              isAdminMenu: true,
                                              component: () => {
                                                  return import(/* webpackChunkName: "newsClassify" */ './views/management/XinWenFenLei/index.vue');
                                              },
                                          },
                                          {
                                              path: '/news',
                                              name: 'news',
                                              meta: {
                                                  icon: "",
                                                  title: "新闻资讯"
                                              },
                                              isAdminMenu: true,
                                              component: () => {
                                                  return import(/* webpackChunkName: "news" */ './views/management/XingWenZiXun/index.vue');
                                              },
                                          },

                                          {
                                              path: '/news/config',
                                              name: 'newsConfig',
                                              component: () => {
                                                  return import(/* webpackChunkName: "newsConfig" */ './views/management/XingWenZiXun/XinWenZiXunConfig/index.vue');
                                              },
                                          },
                                          {
                                              path: '/blogroll',
                                              name: 'blogroll',
                                              meta: {
                                                  icon: "",
                                                  title: "友情链接"
                                              },
                                              isAdminMenu: true,
                                              component: () => {
                                                  return import(/* webpackChunkName: "blogroll" */ './views/management/YouQingLianJie/index.vue');
                                              },
                                          },
                                          {
                                              path: '/Advertising',
                                              name: 'advertising',
                                              meta: {
                                                  icon: "",
                                                  title: "横幅广告"
                                              },
                                              isAdminMenu: true,
                                              component: () => {
                                                  return import(/* webpackChunkName: "Advertising" */ './views/management/Advertising/index.vue');
                                              },
                                          },
                                          {
                                              path: '/register',
                                              name: 'register',
                                              meta: {
                                                  icon: "",
                                                  title: "注册审核"
                                              },
                                              isAdminMenu: true,
                                              component: () => {
                                                  return import(/* webpackChunkName: "register" */ './views/management/RegistrationManagement/index.vue');
                                              },
                                          },
                                          {
                                              path: '/weikezhizuo',
                                              name: 'weikezhizuo',
                                              meta: {
                                                  icon: "",
                                                  title: "微课制作"
                                              },
                                              isAdminMenu: true,
                                              component: () => {
                                                  return import(/* webpackChunkName: "news" */ './views/management/weikezhizuo/index.vue');
                                              },
                                          },
                                          {
                                              path: '/hezuoshangguanli',
                                              name: 'hezuoshangguanli',
                                              meta: {
                                                  icon: "",
                                                  title: "合作商管理"
                                              },
                                              isAdminMenu: true,
                                              component: () => {
                                                  return import(/* webpackChunkName: "news" */ './views/management/hezuoshangguanli/index.vue');
                                              },
                                          },
                                          {
                                              path: '/think',
                                              name: 'think',
                                              meta: {
                                                  icon: "",
                                                  title: "think"
                                              },
                                              isAdminMenu: false,
                                              component: () => {
                                                  return import(/* webpackChunkName: "register" */ './views/think/youqinglianjie/index.vue');
                                              },
                                          },
                                      ],
                                  },
                              ],
                          });

router.beforeEach((to, from, next) => {
    // FIXME 标题 待确认
    document.title = to.meta.title ? '麦塔': '麦塔';
    next();
});

export default router;
