diff --git a/src/ui/login/google-login.tsx b/src/ui/login/google-login.tsx index 5364197..414c374 100644 --- a/src/ui/login/google-login.tsx +++ b/src/ui/login/google-login.tsx @@ -9,28 +9,34 @@ export default function GoogleLogin() { const googleLogin = async (method: string) => { setLoading(true); // 开始请求时设置 loading 为 true - try { - const response = await fetch("/oauth2callback/google/login/", { - method: method, - headers: { - "Content-Type": "application/x-www-form-urlencoded", - }, - }); - console.log("response", response); - if (response.ok) { - console.log("Success:", response); - window.location.href = response.url; - // 处理成功响应 - } else { - console.error("Failed:", response.status); - // 处理失败响应 - } - } catch (error) { - console.error("Error:", error); - // 处理请求错误 - } finally { - setLoading(false); // 请求结束后设置 loading 为 false - } + const form = document.createElement("form"); + form.method = "POST"; + form.action = "/oauth2callback/google/login/"; + + document.body.appendChild(form); + form.submit(); // 提交表单 + // try { + // const response = await fetch("/oauth2callback/google/login/", { + // method: method, + // headers: { + // "Content-Type": "application/x-www-form-urlencoded", + // }, + // }); + // console.log("response", response); + // if (response.ok) { + // console.log("Success:", response); + // window.location.href = response.url; + // // 处理成功响应 + // } else { + // console.error("Failed:", response.status); + // // 处理失败响应 + // } + // } catch (error) { + // console.error("Error:", error); + // // 处理请求错误 + // } finally { + // setLoading(false); // 请求结束后设置 loading 为 false + // } }; return (