import Vue from 'vue'
import Router from 'vue-router'
// 导入刚才编写的组件
import AppIndex from '../components/home/AppIndex'
import Login from '../components/Login'
import Home from "../components/Home"

Vue.use(Router)

export default new Router({
  mode: 'history',
  routes: [
    // 下面都是固定的写法
    {
      path: '/login',
      name: 'Login',
      component: Login
    },
    {
      path: '/',
      name: '/',
      redirect: '/login'
    },
    {
      path: '/home',
      name: 'Home',
      component: Home,
      children: [
        {
          path: '/home',
          name: 'AppIndex',
          component: AppIndex,
          meta: {
            requireAuth: true
          }
        },
        {
          path: '/personal',
          name: 'PersonalCenter',
          component: () => import('../components/page/personal/Index'),
          meta: {
            requireAuth: true
          },
          redirect: '/personal/information',
          children: [
            {
              path: 'information',
              name: 'Information',
              component: () => import('../components/page/personal/Information'),
            },
            {
              path: 'statistics',
              component: () => import('../components/page/personal/Statistics')
            },
            {
              path: 'analysis',
              component: () => import('../components/page/personal/Analysis')
            },
            {
              path: 'rules',
              component: () => import('../components/page/personal/Rules')
            }
          ]
        },
        {
          path: '/overview',
          name: 'OverviewData',
          component: () => import('../components/page/overview/Index'),
          meta: {
            requireAuth: true
          },
          redirect: '/overview/unit',
          children: [
            {
              path: 'unit',
              component: () => import('../components/page/overview/Unit')
            },
            {
              path: 'profession',
              component: () => import('../components/page/overview/Profession')
            },
            {
              path: 'horizontal',
              component: () => import('../components/page/overview/Horizontal')
            },
            {
              path: 'vertical',
              component: () => import('../components/page/overview/Vertical')
            }
          ]
        },
        {
          path: '/result',
          name: 'Result',
          component: () => import('../components/page/result/Index'),
          meta: {
            requireAuth: true
          },
          redirect: '/result/rank',
          children: [
            {
              path: 'rank',
              component: () => import('../components/page/result/Rank')
            },
            {
              path: 'advice',
              component: () => import('../components/page/result/Advice')
            }
          ]
        },
        {
          path: '/permission',
          name: 'Permission',
          component: () => import('../components/page/permission/Index'),
          redirect: '/permission/intake',
          children: [
            {
              path: 'intake',
              component: () => import('../components/page/permission/IntakeData')
            }
          ]
        }
      ]
    },
  ]
})

