fix: 谷歌登陆后不再弹出
This commit is contained in:
parent
d808aa3195
commit
5f3252da6e
|
@ -14,7 +14,7 @@ export default async function AuthButton() {
|
||||||
} = await supabase.auth.getUser();
|
} = await supabase.auth.getUser();
|
||||||
//profiles表 插入用户信息
|
//profiles表 插入用户信息
|
||||||
await insertUserProfile(data, supabase);
|
await insertUserProfile(data, supabase);
|
||||||
console.log("1111 in AuthButton user:", user);
|
// console.log("1111 in AuthButton user:", user);
|
||||||
const signOut = async () => {
|
const signOut = async () => {
|
||||||
"use server";
|
"use server";
|
||||||
|
|
||||||
|
|
|
@ -5,18 +5,25 @@ import { createClient } from "@/utils/supabase/client";
|
||||||
|
|
||||||
const GoogleSignIn = () => {
|
const GoogleSignIn = () => {
|
||||||
const supabase = createClient();
|
const supabase = createClient();
|
||||||
|
|
||||||
// 加载Google身份验证库并初始化
|
// 加载Google身份验证库并初始化
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// 确保gapi脚本只被加载一次
|
// 检查用户是否已经登录
|
||||||
if (!window.gapi) {
|
const session = supabase.auth.getSession();
|
||||||
const script = document.createElement("script");
|
if (session) {
|
||||||
script.src = "https://accounts.google.com/gsi/client";
|
console.log("用户已登录", session);
|
||||||
script.async = true;
|
|
||||||
script.defer = true;
|
|
||||||
script.onload = initGoogleSignIn;
|
|
||||||
document.body.appendChild(script);
|
|
||||||
} else {
|
} else {
|
||||||
initGoogleSignIn();
|
// 确保gapi脚本只被加载一次
|
||||||
|
if (!window.gapi) {
|
||||||
|
const script = document.createElement("script");
|
||||||
|
script.src = "https://accounts.google.com/gsi/client";
|
||||||
|
script.async = true;
|
||||||
|
script.defer = true;
|
||||||
|
script.onload = initGoogleSignIn;
|
||||||
|
document.body.appendChild(script);
|
||||||
|
} else {
|
||||||
|
initGoogleSignIn();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user