From 35fc957eafae1b2b377f043335fd924a2dde8561 Mon Sep 17 00:00:00 2001 From: hailin Date: Thu, 29 Jan 2026 13:01:12 -0800 Subject: [PATCH] =?UTF-8?q?fix(mobile-upgrade):=20=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=A7=A3=E5=8C=85=20mining-admin-service=20TransformIntercepto?= =?UTF-8?q?r=20=E5=93=8D=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mining-admin-service 的 TransformInterceptor 将所有响应包装为 { success, data, timestamp } 格式,导致前端 .map() 调用崩溃。 在 API client 的 response interceptor 中自动检测并解包, 对不包装响应的 admin-service (1.0) 无影响。 Co-Authored-By: Claude Opus 4.5 --- .../src/infrastructure/http/api-client.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/frontend/mobile-upgrade/src/infrastructure/http/api-client.ts b/frontend/mobile-upgrade/src/infrastructure/http/api-client.ts index 4d977194..08899a58 100644 --- a/frontend/mobile-upgrade/src/infrastructure/http/api-client.ts +++ b/frontend/mobile-upgrade/src/infrastructure/http/api-client.ts @@ -79,7 +79,16 @@ export function createApiClient(appType: AppType = 'mobile'): AxiosInstance { }) client.interceptors.response.use( - (response) => response, + (response) => { + // mining-admin-service 的 TransformInterceptor 会将响应包装为 + // { success: true, data: , timestamp: "..." } + // 这里自动解包,使前端代码无需感知包装格式 + const body = response.data + if (body && typeof body === 'object' && !Array.isArray(body) && 'success' in body && 'data' in body) { + response.data = body.data + } + return response + }, (error: AxiosError) => { if (error.response) { const data = error.response.data as { message?: string }