From 7093ed399737ef6484a62c50ae89f19976a8aef0 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 12 Nov 2022 13:27:46 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E5=A4=8D=E3=80=91=E9=92=89?= =?UTF-8?q?=E9=92=89=E7=99=BB=E5=BD=95=E6=97=B6=EF=BC=8C=E9=87=8D=E5=AE=9A?= =?UTF-8?q?=E5=90=91=E5=90=8E=20type=20=E4=B8=A2=E5=A4=B1=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E6=8A=A5=E9=94=99=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/views/login.vue | 3 ++- yudao-ui-admin/src/views/socialLogin.vue | 19 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/yudao-ui-admin/src/views/login.vue b/yudao-ui-admin/src/views/login.vue index 785235dae..280cbd2d7 100644 --- a/yudao-ui-admin/src/views/login.vue +++ b/yudao-ui-admin/src/views/login.vue @@ -258,7 +258,8 @@ export default { // 设置登录中 this.loading = true; // 计算 redirectUri - const redirectUri = location.origin + '/social-login?type=' + socialTypeEnum.type + '&redirect=' + (this.redirect || "/"); // 重定向不能丢 + const redirectUri = location.origin + '/social-login?' + + encodeURIComponent('type=' + socialTypeEnum.type + '&redirect=' + (this.redirect || "/")); // 重定向不能丢 // const redirectUri = 'http://127.0.0.1:48080/api/gitee/callback'; // const redirectUri = 'http://127.0.0.1:48080/api/dingtalk/callback'; // 进行跳转 diff --git a/yudao-ui-admin/src/views/socialLogin.vue b/yudao-ui-admin/src/views/socialLogin.vue index 0dc1abef7..9364cada4 100644 --- a/yudao-ui-admin/src/views/socialLogin.vue +++ b/yudao-ui-admin/src/views/socialLogin.vue @@ -104,24 +104,19 @@ export default { state: undefined, }; }, - // watch: { - // $route: { - // handler: function(route) { - // this.redirect = route.query && route.query.redirect; - // }, - // immediate: true - // } - // }, created() { this.getCookie(); // 验证码开关 this.captchaEnable = getCaptchaEnable(); // 重定向地址 - this.redirect = this.$route.query.redirect ? decodeURIComponent(this.$route.query.redirect) : undefined; + this.redirect = this.getUrlValue('redirect'); // 社交登录相关 - this.type = this.$route.query.type; + this.type = this.getUrlValue('type'); this.code = this.$route.query.code; this.state = this.$route.query.state; + + // 尝试登录一下 + this.loading = true; this.$store.dispatch("SocialLogin", { code: this.code, state: this.state, @@ -183,6 +178,10 @@ export default { }); } }); + }, + getUrlValue(key) { + const url = new URL(decodeURIComponent(location.href)); + return url.searchParams.get(key); } } };