// utils/cloudbase.js // import { init } from '@cloudbase/wx-cloud-client-sdk' // wx.cloud.init({ // // env: 'cloud1-6g98iw7i28b01747', // env: 'honghgaier-5guiffgcf17a2eea', // traceUser: true // }) // const client = init(wx.cloud) // const db = client.database() // const models = client.models // const _ = db.command // ✅ 添加这行,导出查询操作符 // export { db, models, _ } // import { init } from '@cloudbase/wx-cloud-client-sdk' // // 初始化小程序 SDK // wx.cloud.init({ // env: 'honghgaier-5guiffgcf17a2eea', // traceUser: true // }) // const client = init(wx.cloud) // const db = client.database() // const models = client.models // const _ = db.command // export { db, models, _ } // utils/cloudbase.js import { init } from '@cloudbase/wx-cloud-client-sdk' let clientInstance = null export async function getClient() { if (!clientInstance) { const cloud = new wx.cloud.Cloud({ resourceAppid: 'wx1ee76fb4846f8901', resourceEnv: 'honghgaier-5guiffgcf17a2eea', }) await cloud.init() clientInstance = init(cloud) } return clientInstance } export async function getDB() { const client = await getClient() return client.database() } export async function getModels() { const client = await getClient() return client.models } export async function getCommand() { const db = await getDB() return db.command } export async function getTempFileURLs(fileIDs) { const client = await getClient() return client.getTempFileURL({ fileList: fileIDs }).then(res => res.fileList) } // export async function db() { // const db = await getDB() // return { db } // } // export async function models() { // const models = await getModels() // return { models } // } // export async function _() { // const _ = await getCommand() // return { _, } // }