数据分析ui补充完善,接入数据库
This commit is contained in:
@@ -1,34 +1,4 @@
|
||||
// /components/supadb/aksupainstance.uts
|
||||
import { createClient } from './aksupa.uts'
|
||||
|
||||
// 创建并导出 Supabase 客户端实例
|
||||
const supabaseUrl = 'https://your-project.supabase.co' // 替换为你的 Supabase URL
|
||||
const supabaseAnonKey = 'your-anon-key' // 替换为你的匿名密钥
|
||||
|
||||
export const supabase = createClient(supabaseUrl, supabaseAnonKey)
|
||||
|
||||
// 导出 Supabase 实例就绪状态
|
||||
export const isSupabaseReady = true
|
||||
|
||||
// 如果有其他需要导出的函数,可以这样导出:
|
||||
export function initializeSupabase(url: string, key: string) {
|
||||
return createClient(url, key)
|
||||
}
|
||||
|
||||
// 检查连接状态的函数
|
||||
export function checkConnection() {
|
||||
return new Promise((resolve) => {
|
||||
// 模拟连接检查
|
||||
setTimeout(() => {
|
||||
resolve(true)
|
||||
}, 500)
|
||||
})
|
||||
}
|
||||
|
||||
// 不再使用 supaready 变量,而是提供函数
|
||||
export async function ensureSupabaseReady() {
|
||||
return await checkConnection()
|
||||
}
|
||||
import AkSupa from './aksupa.uts'
|
||||
import { SUPA_URL, SUPA_KEY } from '@/ak/config.uts'
|
||||
|
||||
@@ -38,17 +8,23 @@ const supa = new AkSupa(SUPA_URL, SUPA_KEY)
|
||||
// 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();
|
||||
const sess = supa.getSession()
|
||||
if (sess != null && sess.session != null) {
|
||||
return true;
|
||||
return true
|
||||
}
|
||||
// No session found — do not auto sign-in with hard-coded credentials.
|
||||
return true;
|
||||
return true
|
||||
} catch (err) {
|
||||
console.error('Supabase instance init failed', err)
|
||||
return false;
|
||||
return false
|
||||
}
|
||||
})()
|
||||
|
||||
// 兼容具名导出(部分代码使用 import { supabase, ensureSupabaseReady })
|
||||
export const supabase = supa
|
||||
|
||||
export async function ensureSupabaseReady(): Promise<boolean> {
|
||||
return await supaReady
|
||||
}
|
||||
|
||||
export { supaReady }
|
||||
export default supa
|
||||
export default supa
|
||||
|
||||
Reference in New Issue
Block a user