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

import Home from "./views/Home";
import Login from "./views/Login";
import Subject from "./modules/client/views/Subject.vue";
// modules
import client from "./modules/client/router";

Vue.use(Router);
/**
 * 权限控制：
 * 1、不同角色构建不同模块。
 * 2、登录成功之后根据角色注册相应模块。
 * 3、不同模块打包不同文件。（webpackChunkName）
 */

export default new Router({
  routes: [
    {
      path: "/",
      name: "Index",
      redirect: { name: "Login" }
    },
    {
      path: "/login",
      name: "Login",
      component: Login
    },
    {
      path: "/subject",
      name: "Subject",
      component: Subject
    },
    {
      path: "/home",
      name: "Home",
      component: Home,
      children: [...client]
    }
    // [lazy-loaded] route level code-splitting
    // {
    //   path: "/about",
    //   name: "about",
    //   // this generates a separate chunk (about.[hash].js) for this route
    //   // which is lazy-loaded when the route is visited.
    //   component: () =>
    //     import(/* webpackChunkName: "about" */ "./views/About.vue")
    // }
  ]
});
