fix(mobile-upgrade): 自动解包 mining-admin-service TransformInterceptor 响应

mining-admin-service 的 TransformInterceptor 将所有响应包装为
{ success, data, timestamp } 格式,导致前端 .map() 调用崩溃。
在 API client 的 response interceptor 中自动检测并解包,
对不包装响应的 admin-service (1.0) 无影响。

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-29 13:01:12 -08:00
parent 4112b45b9e
commit 35fc957eaf
1 changed files with 10 additions and 1 deletions

View File

@ -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: <actual>, 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 }