作者 RuoYi

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

@@ -23,28 +23,18 @@ router.beforeEach((to, from, next) => { @@ -23,28 +23,18 @@ router.beforeEach((to, from, next) => {
23 // 拉取user_info 23 // 拉取user_info
24 const roles = res.roles 24 const roles = res.roles
25 store.dispatch('GenerateRoutes', { roles }).then(accessRoutes => { 25 store.dispatch('GenerateRoutes', { roles }).then(accessRoutes => {
26 - // 测试 默认静态页面  
27 - // store.dispatch('permission/generateRoutes', { roles }).then(accessRoutes => {  
28 // 根据roles权限生成可访问的路由表 26 // 根据roles权限生成可访问的路由表
29 router.addRoutes(accessRoutes) // 动态添加可访问路由表 27 router.addRoutes(accessRoutes) // 动态添加可访问路由表
30 next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 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 Message.error(err) 32 Message.error(err)
36 next({ path: '/' }) 33 next({ path: '/' })
37 }) 34 })
38 }) 35 })
39 } else { 36 } else {
40 next() 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 } else { 40 } else {
@@ -126,15 +126,12 @@ export default { @@ -126,15 +126,12 @@ export default {
126 Cookies.remove("password"); 126 Cookies.remove("password");
127 Cookies.remove('rememberMe'); 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 }