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

import modelLibrary from "./modelLibrary"; // 模型库
import algorithmsLibrary from "./algorithmsLibrary"; // 算法库
import sceneLibrary from "./sceneLibrary"; // 场景库
import systemManagement from "./systemManagement"; // 账户管理
import workManagement from "./workManagement"; // 工作管理

Vue.use(VueRouter);

const routes = [{
  path: "/",
  name: "index",
  meta: {
    tabname: "首页"
  },
  component: () => import('../views/index'),
  redirect: '/mainPage',
  children: [
      {
        path: "/mainPage",
        name: "mainPage",
        // meta: {
        //   tabname: "首页"
        // },
        component: () => import("../views/mainPage.vue")
      },
      {
        path: "/modelLibrary",
        name: "modelLibrary",
        meta: {
          tabname: "模型库"
        },
        component: () => import("@/views/modelLibrary/index"),
        redirect: '/index',
        children: modelLibrary,
      },
      {
        path: "/algorithmsLibrary",
        name: "algorithmsLibrary",
        meta: {
          tabname: "算法库"
        },
        component: () => import("@/views/algorithmsLibrary/index"),
        redirect: '/index',
        children: algorithmsLibrary,
      },
      {
        path: "/sceneLibrary",
        name: "sceneLibrary",
        meta: {
          tabname: "场景库"
        },
        component: () => import("@/views/sceneLibrary/index"),
        redirect: '/index',
        children: sceneLibrary,
      },
      {
        path: "/workManagement",
        name: "workManagement",
        meta: {
          tabname: "工作管理"
        },
        component: () => import("@/views/workManagement/index"),
        redirect: '/index',
        children: workManagement,
      },
      {
        path: "/systemManagement",
        name: "systemManagement",
        meta: {
          tabname: "系统管理"
        },
        component: () => import("@/views/systemManagement/index"),
        redirect: '/index',
        children: systemManagement,
      }, 
    ]
    .concat([{
      path: "*",
      name: "*",
      component: () => import("../views/mainPage.vue")
    }, ]),
}];
// {
//   path: "/",
//   name: "About",
//   // 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( /* webpackChunkName: "about" */ "../views/About.vue"),
// },


const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
  scrollBehavior(to, from, savedPosition) {
    return {x: 0, y: 0}
}
});

export default router;