继续完善购物逻辑闭环,consumer模块完成度75%

This commit is contained in:
2026-01-26 17:15:51 +08:00
parent be90f1213b
commit f2f208f258
21 changed files with 2516 additions and 217 deletions

View File

@@ -1,4 +1,4 @@
import supa, { supaReady } from '@/components/supadb/aksupainstance.uts'
import { supabase, ensureSupabaseReady } from '@/components/supadb/aksupainstance.uts'
import type { DeviceInfo, DeviceParams } from './types.uts'
// 服务响应类型
@@ -17,8 +17,8 @@ export class SenseDataService {
*/
static async getDevices(params: DeviceParams): Promise<ServiceResponse<Array<DeviceInfo>>> {
try {
await supaReady
const res = await supa.from(SenseDataService.TABLE_NAME)
await ensureSupabaseReady()
const res = await supabase.from(SenseDataService.TABLE_NAME)
.select('*', {})
.eq('user_id', params.user_id)
.execute()
@@ -46,8 +46,8 @@ export class SenseDataService {
*/
static async bindDevice(deviceData: UTSJSONObject): Promise<ServiceResponse<DeviceInfo>> {
try {
await supaReady
const res = await supa.from(SenseDataService.TABLE_NAME)
await ensureSupabaseReady()
const res = await supabase.from(SenseDataService.TABLE_NAME)
.insert(deviceData)
.select('*', {})
.single()
@@ -75,8 +75,8 @@ export class SenseDataService {
*/
static async unbindDevice(deviceId: string): Promise<ServiceResponse<null>> {
try {
await supaReady
const res = await supa.from(SenseDataService.TABLE_NAME)
await ensureSupabaseReady()
const res = await supabase.from(SenseDataService.TABLE_NAME)
.delete()
.eq('id', deviceId)
.execute()
@@ -102,8 +102,8 @@ export class SenseDataService {
*/
static async updateDevice(deviceId: string, configData: UTSJSONObject): Promise<ServiceResponse<DeviceInfo>> {
try {
await supaReady
const res = await supa.from(SenseDataService.TABLE_NAME)
await ensureSupabaseReady()
const res = await supabase.from(SenseDataService.TABLE_NAME)
.update(configData)
.eq('id', deviceId)
.select('*', {})