feat: Implement Supabase authentication, account management UI, and entitlement services.

This commit is contained in:
2569718930@qq.com
2026-03-13 02:23:01 +08:00
parent 987aec2fa6
commit 0a869459c4
34 changed files with 2318 additions and 68 deletions
+29
View File
@@ -0,0 +1,29 @@
import { createBrowserClient } from "@supabase/ssr";
import type { SupabaseClient } from "@supabase/supabase-js";
let cachedClient: SupabaseClient | null = null;
function readSupabasePublicEnv() {
const url = process.env.NEXT_PUBLIC_SUPABASE_URL?.trim();
const anonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY?.trim();
return { anonKey, url };
}
export function hasSupabasePublicEnv() {
const { anonKey, url } = readSupabasePublicEnv();
return Boolean(url && anonKey);
}
export function getSupabaseBrowserClient(): SupabaseClient {
if (cachedClient) {
return cachedClient;
}
const { anonKey, url } = readSupabasePublicEnv();
if (!url || !anonKey) {
throw new Error("Supabase public env is not configured");
}
cachedClient = createBrowserClient(url, anonKey);
return cachedClient;
}