【修复】钉钉登录时,重定向后 type 丢失导致报错的问题

This commit is contained in:
YunaiV 2022-11-12 13:27:46 +08:00
parent 3cd256f7f2
commit 7093ed3997
2 changed files with 11 additions and 11 deletions

View File

@ -258,7 +258,8 @@ export default {
// //
this.loading = true; this.loading = true;
// redirectUri // 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/gitee/callback';
// const redirectUri = 'http://127.0.0.1:48080/api/dingtalk/callback'; // const redirectUri = 'http://127.0.0.1:48080/api/dingtalk/callback';
// //

View File

@ -104,24 +104,19 @@ export default {
state: undefined, state: undefined,
}; };
}, },
// watch: {
// $route: {
// handler: function(route) {
// this.redirect = route.query && route.query.redirect;
// },
// immediate: true
// }
// },
created() { created() {
this.getCookie(); this.getCookie();
// //
this.captchaEnable = getCaptchaEnable(); 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.code = this.$route.query.code;
this.state = this.$route.query.state; this.state = this.$route.query.state;
//
this.loading = true;
this.$store.dispatch("SocialLogin", { this.$store.dispatch("SocialLogin", {
code: this.code, code: this.code,
state: this.state, state: this.state,
@ -183,6 +178,10 @@ export default {
}); });
} }
}); });
},
getUrlValue(key) {
const url = new URL(decodeURIComponent(location.href));
return url.searchParams.get(key);
} }
} }
}; };