chore: 使用同步尝试去除onetap
This commit is contained in:
parent
b5bd878cda
commit
e0426cf5fc
|
@ -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 = () => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user