import Vue from "vue";
import Router from "vue-router";

// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = Router.prototype.push;
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err);
};

Vue.use(Router);

import HomeRoot from "@/views/RootContainer.vue";

export default new Router({
  routes: [
    {
      path: "/",
      name: "home",
      redirect: "/home"
    },
    {
      path: "/home",
      name: "Home",
      // route level code-splitting
      // this generates a separate chunk (about.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import("@/views/home/Home.vue")
    },
    {
      path: "/login",
      name: "Login",
      // route level code-splitting
      // this generates a separate chunk (about.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import("@/views/login/Login.vue")
    },
    {
      path: "/register",
      name: "Register",
      // route level code-splitting
      // this generates a separate chunk (about.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import("@/views/login/Register.vue")
    },
    {
      path: "/translate/projects",
      name: "Home",
      redirect: "/translate/projects",
      component: HomeRoot,
      children: [
        {
          path: "/translate/details",
          name: "TranslateList",
          meta: {
            paths: [
              {
                title: "首页",
                path: "/translate/projects"
              },
              {
                title: "国际化翻译系统"
              }
            ]
          },
          component: () =>
            import(
              /* webpackChunkName: "home" */ "./views/translate/Translate.vue"
            )
        },
        {
          path: "/translate/projects",
          name: "ProjectList",
          meta: {
            paths: [
              {
                title: "首页",
                path: "/translate/projects"
              },
              {
                title: "项目列表"
              }
            ]
          },
          component: () =>
            import(
              /* webpackChunkName: "home" */ "./views/translate/ProjectList.vue"
            )
        },
        {
          path: "/translate/tools",
          name: "TranslateTools",
          meta: {
            paths: [
              {
                title: "首页",
                path: "/translate/projects"
              },
              {
                title: "翻译工具下载"
              }
            ]
          },
          component: () =>
            import(
              /* webpackChunkName: "home" */ "./views/translate/TranslateTools.vue"
            )
        },
        {
          path: "/translate/modules",
          name: "TranslateModules",
          meta: {
            paths: [
              {
                title: "首页",
                path: "/translate/projects"
              },
              {
                title: "翻译模块配置"
              }
            ]
          },
          component: () =>
            import(
              /* webpackChunkName: "home" */ "./views/translate/TranslateModules.vue"
            )
        }
      ]
    }
  ]
});
