修复google登录
This commit is contained in:
parent
4ef7232260
commit
8028fa6f5f
@ -9,28 +9,34 @@ export default function GoogleLogin() {
|
|||||||
|
|
||||||
const googleLogin = async (method: string) => {
|
const googleLogin = async (method: string) => {
|
||||||
setLoading(true); // 开始请求时设置 loading 为 true
|
setLoading(true); // 开始请求时设置 loading 为 true
|
||||||
try {
|
const form = document.createElement("form");
|
||||||
const response = await fetch("/oauth2callback/google/login/", {
|
form.method = "POST";
|
||||||
method: method,
|
form.action = "/oauth2callback/google/login/";
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/x-www-form-urlencoded",
|
document.body.appendChild(form);
|
||||||
},
|
form.submit(); // 提交表单
|
||||||
});
|
// try {
|
||||||
console.log("response", response);
|
// const response = await fetch("/oauth2callback/google/login/", {
|
||||||
if (response.ok) {
|
// method: method,
|
||||||
console.log("Success:", response);
|
// headers: {
|
||||||
window.location.href = response.url;
|
// "Content-Type": "application/x-www-form-urlencoded",
|
||||||
// 处理成功响应
|
// },
|
||||||
} else {
|
// });
|
||||||
console.error("Failed:", response.status);
|
// console.log("response", response);
|
||||||
// 处理失败响应
|
// if (response.ok) {
|
||||||
}
|
// console.log("Success:", response);
|
||||||
} catch (error) {
|
// window.location.href = response.url;
|
||||||
console.error("Error:", error);
|
// // 处理成功响应
|
||||||
// 处理请求错误
|
// } else {
|
||||||
} finally {
|
// console.error("Failed:", response.status);
|
||||||
setLoading(false); // 请求结束后设置 loading 为 false
|
// // 处理失败响应
|
||||||
}
|
// }
|
||||||
|
// } catch (error) {
|
||||||
|
// console.error("Error:", error);
|
||||||
|
// // 处理请求错误
|
||||||
|
// } finally {
|
||||||
|
// setLoading(false); // 请求结束后设置 loading 为 false
|
||||||
|
// }
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user