From 585d2a523bf74310b7b1dc10a00089d44ac5ac6d Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 1 Oct 2022 21:37:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=99=BB=E5=BD=95=E7=9A=84?= =?UTF-8?q?=20redirect=20=E5=9C=B0=E5=9D=80=EF=BC=8C=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E6=97=B6=EF=BC=8C=E7=99=BB=E5=BD=95=E6=88=90?= =?UTF-8?q?=E5=8A=9F=E5=9B=9E=E8=B7=B3=E7=9A=84=E6=97=B6=E5=80=99=E5=9C=B0?= =?UTF-8?q?=E5=9D=80=E4=B8=8D=E6=AD=A3=E7=A1=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-ui-admin/src/permission.js | 3 ++- yudao-ui-admin/src/views/login.vue | 2 +- yudao-ui-admin/src/views/socialLogin.vue | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/yudao-ui-admin/src/permission.js b/yudao-ui-admin/src/permission.js index 525b8b566..3923eb55f 100644 --- a/yudao-ui-admin/src/permission.js +++ b/yudao-ui-admin/src/permission.js @@ -48,7 +48,8 @@ router.beforeEach((to, from, next) => { // 在免登录白名单,直接进入 next() } else { - next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页 + const redirect = encodeURIComponent(to.fullPath) // 编码 URI,保证参数跳转回去后,可以继续带上 + next(`/login?redirect=${redirect}`) // 否则全部重定向到登录页 NProgress.done() } } diff --git a/yudao-ui-admin/src/views/login.vue b/yudao-ui-admin/src/views/login.vue index 1024577b6..3055cd168 100644 --- a/yudao-ui-admin/src/views/login.vue +++ b/yudao-ui-admin/src/views/login.vue @@ -190,7 +190,7 @@ export default { // 验证码开关 this.captchaEnable = getCaptchaEnable(); // 重定向地址 - this.redirect = this.$route.query.redirect; + this.redirect = this.$route.query.redirect ? decodeURIComponent(this.$route.query.redirect) : undefined; this.getCookie(); }, methods: { diff --git a/yudao-ui-admin/src/views/socialLogin.vue b/yudao-ui-admin/src/views/socialLogin.vue index d3463ad66..0dc1abef7 100644 --- a/yudao-ui-admin/src/views/socialLogin.vue +++ b/yudao-ui-admin/src/views/socialLogin.vue @@ -117,7 +117,7 @@ export default { // 验证码开关 this.captchaEnable = getCaptchaEnable(); // 重定向地址 - this.redirect = this.$route.query.redirect; + this.redirect = this.$route.query.redirect ? decodeURIComponent(this.$route.query.redirect) : undefined; // 社交登录相关 this.type = this.$route.query.type; this.code = this.$route.query.code;