chore: 使用同步尝试去除onetap

This commit is contained in:
liuweiqing 2024-03-09 21:55:25 +08:00
parent b5bd878cda
commit e0426cf5fc

View File

@ -8,11 +8,21 @@ const GoogleSignIn = () => {
// 加载Google身份验证库并初始化
useEffect(() => {
// 检查用户是否已经登录
const session = supabase.auth.getSession();
// 异步检查用户是否已经登录
const checkSession = async () => {
const session = await supabase.auth.getSession();
if (session) {
console.log("用户已登录", session);
} else {
loadGoogleSignInScript();
}
};
checkSession();
}, []);
const loadGoogleSignInScript = () => {
// 确保gapi脚本只被加载一次
if (!window.gapi) {
const script = document.createElement("script");
@ -24,8 +34,7 @@ const GoogleSignIn = () => {
} else {
initGoogleSignIn();
}
}
}, []);
};
// 初始化Google登录
const initGoogleSignIn = () => {