修复google登录
This commit is contained in:
parent
4ef7232260
commit
8028fa6f5f
@ -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 (
|
||||
|
Loading…
Reference in New Issue
Block a user