From 8fbefcf65773317a6d461e7ee53bca290af8802e Mon Sep 17 00:00:00 2001 From: wujinliang <2318309077@qq.com> Date: Fri, 18 Sep 2026 11:40:41 +0800 Subject: [PATCH] 1 --- src/api/http.ts | 13 +++++++++---- .../InboundCodeAssociationDialog.test.mjs | 2 ++ .../components/InboundCodeAssociationDialog.vue | 8 ++------ src/modules/first-leg/utils/firstLegOrder.test.mjs | 1 + src/modules/first-leg/utils/firstLegOrder.ts | 5 +++-- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/api/http.ts b/src/api/http.ts index 0d619ee..03d6a18 100644 --- a/src/api/http.ts +++ b/src/api/http.ts @@ -144,6 +144,7 @@ export async function apiRequest(config: AxiosRequestConfig) { export async function apiBlobRequest(config: AxiosRequestConfig) { try { const response = await transport.request({ ...config, responseType: 'blob' }) + await throwBlobApiError(response.data, response.status) return response.data } catch (error) { await throwBlobApiError(error) @@ -154,6 +155,7 @@ export async function apiBlobRequest(config: AxiosRequestConfig) { export async function apiBlobResponseRequest(config: AxiosRequestConfig) { try { const response = await transport.request({ ...config, responseType: 'blob' }) + await throwBlobApiError(response.data, response.status) return { blob: response.data, headers: response.headers } } catch (error) { await throwBlobApiError(error) @@ -161,16 +163,19 @@ export async function apiBlobResponseRequest(config: AxiosRequestConfig) { } } -async function throwBlobApiError(error: unknown) { - if (!axios.isAxiosError(error) || !(error.response?.data instanceof Blob)) return +async function throwBlobApiError(error: unknown, responseStatus?: number) { + const blob = error instanceof Blob + ? error + : axios.isAxiosError(error) && error.response?.data instanceof Blob ? error.response.data : null + if (!blob || !blob.type.toLowerCase().includes('json')) return try { - const body = JSON.parse(await error.response.data.text()) as unknown + const body = JSON.parse(await blob.text()) as unknown if (!isApiEnvelope(body)) return const fieldErrors = asFieldErrors(body.data) throw new ApiError( apiErrorMessage(body.message, fieldErrors), body.code, - error.response.status, + responseStatus ?? (axios.isAxiosError(error) ? error.response?.status : undefined), fieldErrors, typeof body.traceId === 'string' ? body.traceId : null, typeof body.requestId === 'string' ? body.requestId : null, diff --git a/src/modules/first-leg/components/InboundCodeAssociationDialog.test.mjs b/src/modules/first-leg/components/InboundCodeAssociationDialog.test.mjs index 18f0218..e0916b7 100644 --- a/src/modules/first-leg/components/InboundCodeAssociationDialog.test.mjs +++ b/src/modules/first-leg/components/InboundCodeAssociationDialog.test.mjs @@ -6,6 +6,8 @@ const source = readFileSync(new URL('./InboundCodeAssociationDialog.vue', import test('loads only the customer-scoped server association and fails closed', () => { assert.match(source, /getMerchantInboundCodeAssociation\(inboundCode\)/) + assert.match(source, /getFirstLegStatusLabel\(association\.orderStatus\)/) + assert.doesNotMatch(source, /FIRST_LEG_ORDER_STATUSES/) assert.match(source, /association\.value = null/) assert.match(source, /关联摘要加载失败/) assert.match(source, /@click="loadAssociation"/) diff --git a/src/modules/first-leg/components/InboundCodeAssociationDialog.vue b/src/modules/first-leg/components/InboundCodeAssociationDialog.vue index 12fe916..2fc5e02 100644 --- a/src/modules/first-leg/components/InboundCodeAssociationDialog.vue +++ b/src/modules/first-leg/components/InboundCodeAssociationDialog.vue @@ -1,11 +1,11 @@