Shannon_mu 2 vuotta sitten
vanhempi
commit
17c522cd22

+ 1 - 8
commandCenter/src/components/common/Header.vue

@@ -142,13 +142,7 @@ export default {
             this.tagTabIndex = index;
             this.$router.push({ name: item.linkPath });
         },
-        getMenuList() {
-            this.$http.get('/sc-user-center/user/findUserMenu', { appId: '1012' }).then(({ status, data, msg }) => {
-                if (0 == status) {
-                    this.$store.commit('setMenuList', data[0].children);
-                }
-            });
-        },
+     
         setINdex() {
             let index = 0;
             this.menuList.map((item, inx) => {
@@ -161,7 +155,6 @@ export default {
     },
     mounted() {},
     created() {
-        this.getMenuList();
         setInterval(() => {
             this.getTime();
         }, 1000);

+ 29 - 0
commandCenter/src/main.js

@@ -36,7 +36,36 @@ Vue.use(directived);
 Vue.use(ElementUI, {
   size: 'small'
 });
+router.beforeEach((to, from, next) => {
 
+  new Promise((resolve) => {
+
+    http.get('/sc-user-center/user/findUserMenu', { appId: '1012' }).then(({ status, data, msg }) => {
+      if (0 == status) {
+        store.commit('setMenuList', data[0].children);
+        resolve && resolve(true);
+      } else {
+        next('/403')
+      }
+    });
+  }).then(() => {
+    const findMen = (arr, indexPath) => {
+      let isShow = false;
+      arr.map(v => {
+        if ('/' + v.linkPath == indexPath) {
+          isShow = true
+        }
+      });
+      return isShow
+    }
+    if (findMen(store.state.menuList, to.path) || to.path == '/403') {
+      next()
+    } else {
+      to.path !== '/' ? next('/403') : next()
+
+    }
+  });
+});
 new Vue({
   router,
   store,

+ 2 - 1
commandCenter/src/views/commandDispatch/index.vue

@@ -106,7 +106,8 @@ export default {
             if (
                 !!this.$store.getters['getMenuList'] &&
                 !!this.$store.getters['getMenuList'][0] &&
-                !!this.$store.getters['getMenuList'][0].children
+                !!this.$store.getters['getMenuList'][0].children &&
+                !!this.$store.getters['getMenuList'][0].children[0].name == '添加点位'
             ) {
                 return true;
             } else {