Files
medical-mall/components/supadb/aksupainstance.uts
2026-01-29 17:30:39 +08:00

31 lines
903 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// /components/supadb/aksupainstance.uts
import AkSupa from './aksupa.uts'
import { SUPA_URL, SUPA_KEY } from '@/ak/config.uts'
const supa = new AkSupa(SUPA_URL, SUPA_KEY)
// Do not perform hard-coded auto sign-in during page preload (development mode may preload pages).
// Instead, mark supa as ready if an existing session is present; otherwise defer sign-in to explicit user action.
const supaReady: Promise<boolean> = (async () => {
try {
const sess = supa.getSession()
if (sess != null && sess.session != null) {
return true
}
return true
} catch (err) {
console.error('Supabase instance init failed', err)
return false
}
})()
// 兼容具名导出(部分代码使用 import { supabase, ensureSupabaseReady }
export const supabase = supa
export async function ensureSupabaseReady(): Promise<boolean> {
return await supaReady
}
export { supaReady }
export default supa