panhui 5 سال پیش
والد
کامیت
b4bddfa39f
2فایلهای تغییر یافته به همراه14 افزوده شده و 2 حذف شده
  1. 8 1
      src/main/vue/src/router.js
  2. 6 1
      src/main/vue/src/store.js

+ 8 - 1
src/main/vue/src/router.js

@@ -448,6 +448,7 @@ router.beforeEach((to, from, next) => {
         window.open(url);
         return;
     }
+    console.log(store.state.isORGANIZER);
     if (!store.state.userInfo && to.path !== '/login') {
         store
             .dispatch('getUserInfo')
@@ -455,7 +456,11 @@ router.beforeEach((to, from, next) => {
                 store
                     .dispatch('checkOrganization')
                     .then(() => {
-                        next();
+                        if (to.path === '/dashboard' && store.state.isORGANIZER) {
+                            next('/organizationInfo');
+                        } else {
+                            next();
+                        }
                     })
                     .catch(() => {
                         next('/organizationInfo');
@@ -484,6 +489,8 @@ router.beforeEach((to, from, next) => {
                 }
                 next('/organizationInfo');
             });
+    } else if (to.path === '/dashboard' && store.state.isORGANIZER) {
+        next('/organizationInfo');
     } else {
         next();
     }

+ 6 - 1
src/main/vue/src/store.js

@@ -9,7 +9,8 @@ export default new Vuex.Store({
         tableHeight: 0,
         fetchingData: false,
         userInfo: null,
-        organization: null
+        organization: null,
+        isORGANIZER: false
     },
     mutations: {
         updateTableHeight(state, height) {
@@ -23,6 +24,9 @@ export default new Vuex.Store({
         },
         updateOrganization(state, organization) {
             state.organization = organization;
+        },
+        updateIsORGANIZER(state, isORGANIZER) {
+            state.isORGANIZER = isORGANIZER;
         }
     },
     actions: {
@@ -34,6 +38,7 @@ export default new Vuex.Store({
                     let flag = res.data.authorities.find(item => {
                         return item.name == 'ROLE_ORGANIZER';
                     });
+                    context.commit('updateIsORGANIZER', !!flag);
                     if (flag) {
                         return http.axios.get('/organization/getByUserId/' + res.data.id);
                     } else {