import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect:'/projectApplication'
  },
  {
    name:'login',
    path:'/login',
    component:()=>import('@/views/login.vue'), 
    meta:{isAuth:false}
  },
  {  //项目立项申请
    name:"projectApplicationApplyMain",
    path:"/projectApplicationApplyMain",
    component:()=>import('@/views/projectApply/projectApplicationApplyMain.vue'),
    meta:{isAuth:true}
  },
  {  //活动管理
    name:"makerActvityApplyMain",
    path:"/makerActvityApplyMain",
    component:()=>import('@/views/activityManage/makerActvityApplyMain.vue'),
    meta:{isAuth:true}
  },
 
  { //成果展示
    name:'resultShowDetail',
    path:'/resultShowDetail',
    component:()=>import('@/views/resultShow/resultShowDetail.vue'),
    meta:{isAuth:true}

  },
  {
    name:'home',
    path:'/home',
    component:()=>import('@/views/home.vue'),
    meta:{isAuth:true},

    children:[
      { //创客活动
        name:'makerActvity',
        path:'/makerActvity',
        component:()=>import('@/views/activityManage/makerActvity.vue'),
        meta:{isAuth:true}

      },
      { //创客活动详情
        name:'makerActvityDetails',
        path:'/makerActvityDetails',
        component:()=>import('@/views/activityManage/makerActvityDetails.vue'),
        meta:{isAuth:true}
      },
      { //项目立项申请
        name:'projectApplication',
        path:'/projectApplication',
        component:()=>import('@/views/projectApply/projectApplication.vue'),
        meta:{isAuth:true}

      },
      {
        name:'projectApplicationDetails',
        path:'/projectApplicationDetails',
        component:()=>import('@/views/projectApply/projectApplicationDetails.vue'),
        meta:{isAuth:true}

      },
      {
        name:'projectApplication2',
        path:'/projectApplication2',
        component:()=>import('@/views/projectApply/projectApplication2.vue'),
        meta:{isAuth:true}

      },
      { //学分登记
        name:'credit',
        path:'/credit',
        component:()=>import('@/views/credit/credit.vue'),
        meta:{isAuth:true}

      },
      { //学分登记
        name:'credit1',
        path:'/credit1',
        component:()=>import('@/views/credit/credit1.vue'),
        meta:{isAuth:true}

      },
      { //创业公司登记
        name:'firm',
        path:'/firm',
        component:()=>import('@/views/firm.vue'),
        meta:{isAuth:true}

      },
      { //创客资金
        name:'makerfund',
        path:'/makerfund',
        component:()=>import('@/views/fundManage/makerfund.vue'),
        meta:{isAuth:true}

      },
      { //创客资金
        name:'makerfundApply',
        path:'/makerfundApply',
        component:()=>import('@/views/fundManage/makerfundApply.vue'),
        meta:{isAuth:true}

      },
      { //创客资金
        name:'makerfundDetails',
        path:'/makerfundDetails',
        component:()=>import('@/views/fundManage/makerfundDetails.vue'),
        meta:{isAuth:true}

      },
      { //消息通知
        name:'messageNotification',
        path:'/messageNotification',
        component:()=>import('@/views/messageNotification.vue'),
        meta:{isAuth:true}

      },
      { //项目管理
        name:'ProjectManagement',
        path:'/ProjectManagement',
        component:()=>import('@/views/projectManage/ProjectManagement.vue'),
        meta:{isAuth:true}

      },
      { //项目管理
        name:'ProjectManagement2',
        path:'/ProjectManagement2',
        component:()=>import('@/views/projectManage/ProjectManagement2.vue'),
        meta:{isAuth:true}

      },
      { //项目管理
        name:'ProjectManagement3',
        path:'/ProjectManagement3',
        component:()=>import('@/views/projectManage/ProjectManagement3.vue'),
        meta:{isAuth:true}

      },
      { //项目管理
        name:'ProjectManagement4',
        path:'/ProjectManagement4',
        component:()=>import('@/views/projectManage/ProjectManagement4.vue'),
        meta:{isAuth:true}
      },
      {
        name:'ProjectManagement3_1',
        path:'/ProjectManagement3_1',
        component:()=>import('@/views/projectManage/ProjectManagement3_1.vue'),
        meta:{isAuth:true}
      },
      { //项目管理
        name:'ProjectManagement5',
        path:'/ProjectManagement5',
        component:()=>import('@/views/projectManage/ProjectManagement5.vue'),
        meta:{isAuth:true}

      },
      { //项目管理
        name:'ProjectManagement1',
        path:'/ProjectManagement1',
        component:()=>import('@/views/projectManage/ProjectManagement1.vue'),
        meta:{isAuth:true}

      },
      { //项目资金管理
        name:'ProjectManagementFund1',
        path:'/ProjectManagementFund1',
        component:()=>import('@/views/projectManage/ProjectManagementFund1.vue'),
        meta:{isAuth:true}

      },
      { //项目资金管理
        name:'ProjectManagementFund2',
        path:'/ProjectManagementFund2',
        component:()=>import('@/views/projectManage/ProjectManagementFund2.vue'),
        meta:{isAuth:true}

      },
      { //项目结项
        name:'projectSettlement',
        path:'/projectSettlement',
        component:()=>import('@/views/projectSettlement/projectSettlement.vue'),
        meta:{isAuth:true}

      },
      { //项目结项
        name:'projectSettlement1',
        path:'/projectSettlement1',
        component:()=>import('@/views/projectSettlement/projectSettlement1.vue'),
        meta:{isAuth:true}

      },
      { //项目结项
        name:'projectSettlement2',
        path:'/projectSettlement2',
        component:()=>import('@/views/projectSettlement/projectSettlement2.vue'),
        meta:{isAuth:true}

      },
      { //成果展示
        name:'resultsShow',
        path:'/resultsShow',
        component:()=>import('@/views/resultShow/resultsShow.vue'),
        meta:{isAuth:true}

      },
      
    ]
  }
]

const router = new VueRouter({
  routes,
})

// router.beforeEach((to,from,next)=>{
//     if(to.meta.isAuth){
//       if(localStorage.getItem('isAuth') === "true"){
//         next();
//       }else{
//         return next('/login')
//       }
//     }else{
//       next()
//     }
//   }
// )
// router.beforeEach(function(to, from, next) {
//   if (to.meta.isAuth) {
//     //页面是否登录
//     if (localStorage.getItem("token")) {
//       //本地存储中是否有token(uid)数据
//       next(); //表示已经登录
//     } else {
//       //next可以传递一个路由对象作为参数 表示需要跳转到的页面
//       next({
//         name: "login"
//       });
//     }
//   } else {
//     //表示不需要登录
//     next(); //继续往后走
//   }
// });

export default router
