Commit 585d2a523bf74310b7b1dc10a00089d44ac5ac6d

Authored by YunaiV
1 parent ab40254b

修复登录的 redirect 地址,存在参数时,登录成功回跳的时候地址不正确的问题

yudao-ui-admin/src/permission.js
@@ -48,7 +48,8 @@ router.beforeEach((to, from, next) => { @@ -48,7 +48,8 @@ router.beforeEach((to, from, next) => {
48 // 在免登录白名单,直接进入 48 // 在免登录白名单,直接进入
49 next() 49 next()
50 } else { 50 } else {
51 - next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页 51 + const redirect = encodeURIComponent(to.fullPath) // 编码 URI,保证参数跳转回去后,可以继续带上
  52 + next(`/login?redirect=${redirect}`) // 否则全部重定向到登录页
52 NProgress.done() 53 NProgress.done()
53 } 54 }
54 } 55 }
yudao-ui-admin/src/views/login.vue
@@ -190,7 +190,7 @@ export default { @@ -190,7 +190,7 @@ export default {
190 // 验证码开关 190 // 验证码开关
191 this.captchaEnable = getCaptchaEnable(); 191 this.captchaEnable = getCaptchaEnable();
192 // 重定向地址 192 // 重定向地址
193 - this.redirect = this.$route.query.redirect; 193 + this.redirect = this.$route.query.redirect ? decodeURIComponent(this.$route.query.redirect) : undefined;
194 this.getCookie(); 194 this.getCookie();
195 }, 195 },
196 methods: { 196 methods: {
yudao-ui-admin/src/views/socialLogin.vue
@@ -117,7 +117,7 @@ export default { @@ -117,7 +117,7 @@ export default {
117 // 验证码开关 117 // 验证码开关
118 this.captchaEnable = getCaptchaEnable(); 118 this.captchaEnable = getCaptchaEnable();
119 // 重定向地址 119 // 重定向地址
120 - this.redirect = this.$route.query.redirect; 120 + this.redirect = this.$route.query.redirect ? decodeURIComponent(this.$route.query.redirect) : undefined;
121 // 社交登录相关 121 // 社交登录相关
122 this.type = this.$route.query.type; 122 this.type = this.$route.query.type;
123 this.code = this.$route.query.code; 123 this.code = this.$route.query.code;