Q-ABAB 2 年之前
父节点
当前提交
7eb9ccedb4
共有 1 个文件被更改,包括 41 次插入38 次删除
  1. 41 38
      src/router/index.js

+ 41 - 38
src/router/index.js

@@ -1,11 +1,14 @@
 import Vue from 'vue'
 import VueRouter from 'vue-router'
+import store from '@/config/config'
 
 Vue.use(VueRouter)
 const originalPush = VueRouter.prototype.push
 VueRouter.prototype.push = function push(location) {
   return originalPush.call(this, location).catch(err => err)
 }
+
+
 const routes = [{
         path: '/',
         redirect: '/projectApplication'
@@ -15,7 +18,7 @@ const routes = [{
         path: '/login',
         component: () =>
             import ('@/views/login.vue'),
-        meta: { isAuth: false }
+        meta: { isAuth: false,checkPower:true }
     },
 
     { //成果展示
@@ -23,7 +26,7 @@ const routes = [{
         path: '/resultShowDetail',
         component: () =>
             import ('@/views/resultShow/resultShowDetail.vue'),
-        meta: { isAuth: true }
+        meta: { isAuth: true,checkPower:false }
 
     },
     { //测试
@@ -31,7 +34,7 @@ const routes = [{
         path: '/test',
         component: () =>
             import ('@/views/test.vue'),
-        meta: { isAuth: true }
+        meta: { isAuth: true,checkPower:true }
 
     },
     { //测试2
@@ -39,7 +42,7 @@ const routes = [{
         path: '/Word',
         component: () =>
             import ('@/views/Word.vue'),
-        meta: { isAuth: true }
+        meta: { isAuth: true,checkPower:true }
 
     },
     {
@@ -47,54 +50,54 @@ const routes = [{
         path: '/home',
         component: () =>
         import ('@/views/home.vue'),
-        meta: { isAuth: true },
+        meta: { isAuth: true,checkPower:false },
 
         children: [{ //创客活动
                 name: 'makerActvity',
                 path: '/makerActvity',
                 component: () =>import ('@/views/activityManage/makerActvity.vue'),
-                meta: { isAuth: true }
+                meta: { isAuth: true,checkPower:false }
 
             },
             { //创客活动详情
                 name: 'makerActivityWordDetail',
                 path: '/makerActvityWordDetail',
                 component: () =>import ('@/views/activityManage/makerActivityWordDetail.vue'),
-                meta: { isAuth: true }
+                meta: { isAuth: true,checkPower:false }
             },
             { //项目立项申请
                 name: 'projectApplication',
                 path: '/projectApplication',
                 component: () =>import ('@/views/projectApply/projectApplication.vue'),
-                meta: { isAuth: true }
+                meta: { isAuth: true,checkPower:false }
 
             },
             { //新学生项目立项申请
                 name: 'newStudentProjectApply',
                 path: '/newStudentProjectApply',
                 component: () =>import ('@/views/projectApply/newStudentProjectApply.vue'),
-                meta: { isAuth: true }
+                meta: { isAuth: true,checkPower:false }
 
             },
             { //新创客活动
                 name: 'newMarkerActivity',
                 path: '/newMarkerActivity',
                 component: () =>import ('@/views/activityManage/newMarkerActivity'),
-                meta: { isAuth: true }
+                meta: { isAuth: true,checkPower:false }
 
             },
             { //新个人创客
                 name: 'newNomMarkerActivity',
                 path: '/newNomMarkerActivity',
                 component: () =>import ('@/views/activityManage/newNomMarkerActivity.vue'),
-                meta: { isAuth: true }
+                meta: { isAuth: true,checkPower:false }
 
             },
             {   //项目查看详细
                 name: 'projectApplicationDetailMain',
                 path: '/projectApplicationDetailMain',
                 component: () =>import ('@/views/projectApply/projectApplicationDetailMain.vue'),
-                meta: { isAuth: true }
+                meta: { isAuth: true,checkPower:false }
 
             },
 
@@ -102,40 +105,40 @@ const routes = [{
                 name: 'firm',
                 path: '/firm',
                 component: () =>import ('@/views/firm.vue'),
-                meta: { isAuth: true }
+                meta: { isAuth: true,checkPower:true }
 
             },
             { //创客资金主页面
                 name: 'makerfund',
                 path: '/makerfund',
                 component: () =>import ('@/views/fundManage/makerfund.vue'),
-                meta: { isAuth: true }
+                meta: { isAuth: true,checkPower:false }
 
             },
             { //新创客活动资金申请
                 name: 'newMarkerfundApply',
                 path: '/newMarkerfundApply',
                 component: () =>import ('@/views/fundManage/newMarkerfundApply.vue'),
-                meta: { isAuth: true }
+                meta: { isAuth: true,checkPower:false }
             },
             { //新个人创客资金申请
                 name: 'newNomMarkerFundApply',
                 path: '/newNomMarkerFundApply',
                 component: () =>import ('@/views/fundManage/newNomMarkerFundApply.vue'),
-                meta: { isAuth: true }
+                meta: { isAuth: true,checkPower:false }
 
             },
             { //创客资金详情
                 name: 'makerfundDetails',
                 path: '/makerfundDetails',
                 component: () =>import ('@/views/fundManage/makerfundDetails.vue'),
-                meta: { isAuth: true }
+                meta: { isAuth: true,checkPower:false }
             },
             { //消息通知
                 name: 'messageNotification',
                 path: '/messageNotification',
                 component: () =>import ('@/views/messageNotification.vue'),
-                meta: { isAuth: true }
+                meta: { isAuth: true,checkPower:true }
 
             },
 
@@ -144,14 +147,14 @@ const routes = [{
                 name: 'ProjectManagement',
                 path: '/ProjectManagement',
                 component: () =>import ('@/views/projectManage/ProjectManagement.vue'),
-                meta: { isAuth: true }
+                meta: { isAuth: true,checkPower:true }
 
             },
             {   //项目管理父查看详情
                 name: 'ProjectManagementMain',
                 path: '/ProjectManagementMain',
                 component: () =>import ('@/views/projectManage/ProjectManagementMain.vue'),
-                meta: { isAuth: true }
+                meta: { isAuth: true,checkPower:true }
             },
  
             
@@ -159,7 +162,7 @@ const routes = [{
                 name: 'ProjectManagementFundDetail',
                 path: '/ProjectManagementFundDetail',
                 component: () =>import ('@/views/projectManage/ProjectManagementFundDetail.vue'),
-                meta: { isAuth: true }
+                meta: { isAuth: true,checkPower:true }
 
             },
             // { //项目资金管理
@@ -173,33 +176,33 @@ const routes = [{
                 name: 'projectSettlement',
                 path: '/projectSettlement',
                 component: () =>import ('@/views/projectSettlement/projectSettlement.vue'),
-                meta: { isAuth: true }
+                meta: { isAuth: true,checkPower:true }
 
             },
             {   //项目结项查看详细
                 name:"projectSettlementDetailMain",
                 path:"/projectSettlementDetailMain",
                 component:()=>import('@/views/projectSettlement/projectSettlementDetailMain.vue'),
-                meta:{isAuth:true}
+                meta:{isAuth:true,checkPower:true}
             },
             
             { //成果展示
                 name: 'resultsShow',
                 path: '/resultsShow',
                 component: () =>import ('@/views/resultShow/resultsShow.vue'),
-                meta: { isAuth: true }
+                meta: { isAuth: true,checkPower:true }
             },
             { //数据检测
                 name: 'echarts',
                 path: '/echarts',
                 component: () =>import ('@/views/echarts/echarts.vue'),
-                meta: { isAuth: true }
+                meta: { isAuth: true,checkPower:true }
             },
             {//创客空间项目申请
                 name:"/MakerSpaceApply",
                 path:"/MakerSpaceApply",
                 component:()=>import('@/views/projectApply/MakerSpaceApply.vue'),
-                meta:{isAuth:true}
+                meta:{isAuth:true,checkPower:false}
             },
         ]
     }
@@ -211,18 +214,18 @@ 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((to,from,next)=>{
+    if(to.meta.checkPower){
+        if(store.state.userInfo.type==0){
+            next();
+        }else{
+            router.push('/projectApplication')
+        }
+    }else{
+        next();
+    }
+  }
+)
 // router.beforeEach(function(to, from, next) {
 //   if (to.meta.isAuth) {
 //     //页面是否登录