尝试更新了wechatPublic登录的state为空问题

This commit is contained in:
Xu Chang 2024-05-22 22:24:23 +08:00
parent fd3104d7e0
commit 9e6922e468
2 changed files with 4 additions and 4 deletions

View File

@ -38,7 +38,7 @@ function Grant(props) {
const url = new URL(decodeURIComponent(redirectUri)); const url = new URL(decodeURIComponent(redirectUri));
url.searchParams.set('code', code); url.searchParams.set('code', code);
if (state) { if (state) {
url.searchParams.set('state', state); url.searchParams.set('state', state || window.location.pathname);
} }
window.location.href = url.toString(); window.location.href = url.toString();
setTimeout(() => { setTimeout(() => {
@ -69,7 +69,7 @@ function Grant(props) {
return; return;
} }
setDisabled2(true); setDisabled2(true);
const url = WeChatLoginUrl(redirectUri, appId, scope, state ? `&state=${state}` : ''); const url = WeChatLoginUrl(redirectUri, appId, scope, `&state=${state || window.location.pathname}`);
window.location.href = url; window.location.href = url;
setTimeout(() => { setTimeout(() => {
setDisabled2(false); setDisabled2(false);

View File

@ -86,7 +86,7 @@ function Grant(props: GrantProps) {
); );
url.searchParams.set('code', code); url.searchParams.set('code', code);
if (state) { if (state) {
url.searchParams.set('state', state); url.searchParams.set('state', state || window.location.pathname);
} }
window.location.href = url.toString(); window.location.href = url.toString();
@ -130,7 +130,7 @@ function Grant(props: GrantProps) {
redirectUri, redirectUri,
appId, appId,
scope, scope,
state ? `&state=${state}` : '' `&state=${state || window.location.pathname}`,
); );
window.location.href = url; window.location.href = url;