0.3.1 UI修复

This commit is contained in:
liaibo
2026-01-18 19:01:31 +08:00
parent 90a38b48cf
commit 8a5b915002
86 changed files with 1160 additions and 2867 deletions
@@ -1,51 +0,0 @@
"use client";
import { useEffect } from "react";
import type { Session } from "@supabase/supabase-js";
import { SessionContextProvider } from "@supabase/auth-helpers-react";
import { getSupabaseBrowserClient } from "@/lib/supabase/client";
interface SupabaseProviderProps {
session: Session | null;
children: React.ReactNode;
}
export function SupabaseProvider({ session, children }: SupabaseProviderProps) {
useEffect(() => {
const supabaseBrowser = getSupabaseBrowserClient();
const {
data: { subscription },
} = supabaseBrowser.auth.onAuthStateChange((_event, newSession) => {
fetch("/api/auth/callback", {
method: "POST",
headers: { "Content-Type": "application/json" },
credentials: "include",
body: JSON.stringify({ event: _event, session: newSession }),
});
});
supabaseBrowser.auth.getSession().then(({ data }) => {
if (data.session) {
fetch("/api/auth/callback", {
method: "POST",
headers: { "Content-Type": "application/json" },
credentials: "include",
body: JSON.stringify({ event: "INITIAL_SESSION", session: data.session }),
});
}
});
return () => {
subscription.unsubscribe();
};
}, []);
return (
<SessionContextProvider
supabaseClient={getSupabaseBrowserClient()}
initialSession={session}
>
{children}
</SessionContextProvider>
);
}