import Vue from 'vue';
import VueRouter, { RouteConfig } from 'vue-router';
import Main from '@/views/Main.vue';

Vue.use(VueRouter);

const routes: RouteConfig[] = [
  {
    path: '/',
    name: 'Main',
    component: Main,
    children: [
      {
        path: '',
        name: 'TemplateList',
        // 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/template/Index.vue'),
      },
      {
        path: '/proofList',
        name: 'ProofList',
        // 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/proof/Index.vue'),
        meta: { requiresAuth: true },
      },
      {
        path: '/userCenter/index',
        name: 'UserCenter',
        // 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/userCenter/Index.vue'),
      },
    ],
  },
  {
    path: '/proofDetail',
    name: 'ProofDetail',
    // 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/proof/Detail.vue'),
    props: (route) => ({ templateId: route.query.templateId,
        proofId: route.query.proofId,
        baseProof: route.query.baseProof,
        preProof: route.query.preProof,
      }),
    meta: { requiresAuth: true },
  },
  {
    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(/* webpackChunkName: "about" */ '@/views/Login.vue'),
  },
  {
    path: '/viewCode',
    name: 'ViewCode',
    // 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/ViewCode.vue'),
    meta: { requiresAuth: true },
  },
  {
    path: '/recycleList',
    name: 'RecycleList',
    // 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/userCenter/RecycleList.vue'),
    meta: { requiresAuth: true },
  },
  {
    path: '/addTemplate',
    name: 'Add',
    // 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/template/Add.vue'),
    meta: { requiresAuth: true },
  },
  {
    path: '/templList',
    name: 'TemplList',
    // 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/template/List.vue'),
    props: (route) => ({ templList: route.query.templList }),
    meta: { requiresAuth: true },
  },
  {
    path: '/recharge',
    name: 'Recharge',
    // 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/userCenter/Recharge.vue'),
    props: (route) => ({ templList: route.query.templList }),
    meta: { requiresAuth: true },
  },
  {
    path: '/contect',
    name: 'Contect',
    // 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/userCenter/Contect.vue'),
    props: (route) => ({ templList: route.query.templList }),
    meta: { requiresAuth: true },
  },
  {
    path: '/rechargeRecord',
    name: 'RechargeRecord',
    // 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/userCenter/RechargeRecord.vue'),
    props: (route) => ({ templList: route.query.templList }),
    meta: { requiresAuth: true },
  },
  {
    path: '/accountNum',
    name: 'AccountNum',
    // 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/userCenter/AccountNum.vue'),
    meta: { requiresAuth: true },
  },
  {
    path: '/setPasswd',
    name: 'SetPasswd',
    // 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/userCenter/SetPasswd.vue'),
    meta: { requiresAuth: true },
  },
  {
    path: '/setPhone',
    name: 'SetPhone',
    // 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/userCenter/SetPhone.vue'),
    meta: { requiresAuth: true },
  },
  {
    path: '/auth/personal',
    name: 'Personal',
    // 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/auth/Personal.vue'),
  },
  {
    path: '/auth/company',
    name: 'Enterprise',
    // 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/auth/Enterprise.vue'),
  },
  {
    path: '/auth/personal',
    name: 'Personal',
    // 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/auth/Personal.vue'),
  },
  {
    path: '/auth/index',
    name: 'Auth',
    // 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/auth/Index.vue'),
  },
];

const router = new VueRouter({
  routes,
});

export default router;
