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