Bladeren bron

登录后push添加catch防止出现检查错误

RuoYi 5 jaren geleden
bovenliggende
commit
88aff5d8a7
2 gewijzigde bestanden met toevoegingen van 8 en 21 verwijderingen
  1. 2 12
      ruoyi-ui/src/permission.js
  2. 6 9
      ruoyi-ui/src/views/login.vue

+ 2 - 12
ruoyi-ui/src/permission.js

@@ -23,28 +23,18 @@ router.beforeEach((to, from, next) => {
23 23
           // 拉取user_info
24 24
           const roles = res.roles
25 25
           store.dispatch('GenerateRoutes', { roles }).then(accessRoutes => {
26
-          // 测试 默认静态页面
27
-          // store.dispatch('permission/generateRoutes', { roles }).then(accessRoutes => {
28 26
             // 根据roles权限生成可访问的路由表
29 27
             router.addRoutes(accessRoutes) // 动态添加可访问路由表
30 28
             next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
31 29
           })
32
-        })
33
-          .catch(err => {
34
-            store.dispatch('FedLogOut').then(() => {
30
+        }).catch(err => {
31
+            store.dispatch('LogOut').then(() => {
35 32
               Message.error(err)
36 33
               next({ path: '/' })
37 34
             })
38 35
           })
39 36
       } else {
40 37
         next()
41
-        // 没有动态改变权限的需求可直接next() 删除下方权限判断 ↓
42
-        // if (hasPermission(store.getters.roles, to.meta.roles)) {
43
-        //   next()
44
-        // } else {
45
-        //   next({ path: '/401', replace: true, query: { noGoBack: true }})
46
-        // }
47
-        // 可删 ↑
48 38
       }
49 39
     }
50 40
   } else {

+ 6 - 9
ruoyi-ui/src/views/login.vue

@@ -126,15 +126,12 @@ export default {
126 126
             Cookies.remove("password");
127 127
             Cookies.remove('rememberMe');
128 128
           }
129
-          this.$store
130
-            .dispatch("Login", this.loginForm)
131
-            .then(() => {
132
-              this.$router.push({ path: this.redirect || "/" });
133
-            })
134
-            .catch(() => {
135
-              this.loading = false;
136
-              this.getCode();
137
-            });
129
+          this.$store.dispatch("Login", this.loginForm).then(() => {
130
+            this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
131
+          }).catch(() => {
132
+            this.loading = false;
133
+            this.getCode();
134
+          });
138 135
         }
139 136
       });
140 137
     }