diff --git a/src/api/returnunpack.ts b/src/api/returnunpack.ts index 0e088b3..768e473 100644 --- a/src/api/returnunpack.ts +++ b/src/api/returnunpack.ts @@ -171,12 +171,14 @@ export function pickApiData(res: unknown): any { export function parseStockWarehouseSearch(res: unknown): { list: any[]; total: number } { if (!isReturnUnpackOk(res)) return { list: [], total: 0 } const payload = pickApiData(res) + // 顶层响应体(res 非对象时用空对象兜底,避免属性访问报错) + const body = (res && typeof res === 'object' ? res : {}) as Record let list: any[] = [] if (Array.isArray(payload?.list)) list = payload.list else if (Array.isArray(payload)) list = payload - else if (Array.isArray(res?.list)) list = (res as any).list - else if (Array.isArray(res?.data)) list = (res as any).data - const total = Number(payload?.total ?? (res as any)?.total ?? list.length) + else if (Array.isArray(body.list)) list = body.list + else if (Array.isArray(body.data)) list = body.data + const total = Number(payload?.total ?? body.total ?? list.length) return { list, total: Number.isFinite(total) ? total : list.length } } diff --git a/src/components/top-nav.vue b/src/components/top-nav.vue index 3d970b7..9b69975 100644 --- a/src/components/top-nav.vue +++ b/src/components/top-nav.vue @@ -15,6 +15,14 @@ + + {{ voiceEnabled ? '语音开' : '语音关' }} + + 广播 @@ -51,6 +59,8 @@