前端各页面对接数据

This commit is contained in:
2026-02-02 17:34:31 +08:00
parent d57592ca7d
commit b6200cda28
25 changed files with 7634 additions and 1977 deletions

View File

@@ -800,6 +800,13 @@ async select(table : string, filter ?: string | null, options ?: AkSupaSelectOpt
headers['Prefer'] = 'return=representation,single-object';
}
}
// 确保有 select 参数
if (options.columns == null) {
params.push('select=*');
} else if (options.columns == "") {
params.push('select=*');
}
} else {
params.push('select=*');
}

View File

@@ -1,54 +1,34 @@
// /components/supadb/aksupainstance.uts
import { createClient } from './aksupa.uts'
import { SUPA_URL, SUPA_KEY } from '@/ak/config.uts'
// 创建并导出 Supabase 客户端实例
const supabaseUrl = 'https://your-project.supabase.co' // 替换为你的 Supabase URL
const supabaseAnonKey = 'your-anon-key' // 替换为你的匿名密钥
// 创建单一真实的 Supabase 客户端实例 (使用 config.uts 配置)
// Create single source of truth client using config
const supaInstance = createClient(SUPA_URL, SUPA_KEY)
export const supabase = createClient(supabaseUrl, supabaseAnonKey)
// 导出默认实例 (供 login.uvue 等使用)
export default supaInstance
// 导出 Supabase 实例就绪状态
// 导出命名实例 'supabase' (供 store.uts 使用)
export const supabase = supaInstance
// 导出 isSupabaseReady 状态
export const isSupabaseReady = true
// 兼容 ensureSupabaseReady
export async function ensureSupabaseReady() {
return true
}
// 检查连接状态的函数
export function checkConnection() {
return Promise.resolve(true)
}
// 兼容 supaReady Promise
export const supaReady = Promise.resolve(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'
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;
}
// No session found — do not auto sign-in with hard-coded credentials.
return true;
} catch (err) {
console.error('Supabase instance init failed', err)
return false;
}
})()
export { supaReady }
export default supa