From eaffae4af0af5eb0b9b0f306399bfad2f7a6b140 Mon Sep 17 00:00:00 2001 From: yml2213 Date: Sun, 25 Oct 2026 17:29:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(frontend):=20=E6=94=AF=E6=8C=81=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E7=BA=A7=E8=87=AA=E5=AE=9A=E4=B9=89=E8=B6=85=E6=97=B6?= =?UTF-8?q?=E5=B9=B6=E5=B0=86=E6=8E=A5=E5=8D=95=E6=A8=A1=E6=9D=BF=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E4=B8=8E=E6=89=B9=E9=87=8F=E5=9B=9E=E5=A1=AB?= =?UTF-8?q?=E8=B6=85=E6=97=B6=E5=BB=B6=E9=95=BF=E8=87=B35=E5=88=86?= =?UTF-8?q?=E9=92=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 http 客户端封装中增加可选 RequestOptions 参数透传,允许对耗时较长的数据初始化/大批量回填接口单独配置超时 - 将 applyAdminTemplateProductBootstrap、syncAdminAffiliateDashCostSnapshots、backfillAdminProductMappings 及 backfillAdminNormalizedQuantities 客户端超时由 50 秒延长至 300 秒(5分钟) - 彻底解决生产全量订单数据规模下接单模板初始化触发 50 秒网络超时提示的问题 - 验证方式:npm --prefix apps/frontend run typecheck 通过,生产镜像构建运行正常 --- apps/frontend/src/lib/http.ts | 18 ++++++++++++------ .../frontend/src/services/admin/cost-center.ts | 7 ++++--- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/apps/frontend/src/lib/http.ts b/apps/frontend/src/lib/http.ts index 8998194e..666e0b75 100644 --- a/apps/frontend/src/lib/http.ts +++ b/apps/frontend/src/lib/http.ts @@ -182,40 +182,46 @@ function request(config: Parameters>>[0]) return http.request, ApiEnvelope>(config) } -export function apiGet(url: string, params?: Record) { - return request({ method: 'GET', url, params }) +type RequestOptions = Partial[0]> + +export function apiGet(url: string, params?: Record, options?: RequestOptions) { + return request({ method: 'GET', url, params, ...options }) } -export function apiGetBlob(url: string, params?: Record) { +export function apiGetBlob(url: string, params?: Record, options?: RequestOptions) { return http.request({ method: 'GET', url, params, responseType: 'blob', + ...options, }) } -export function apiPost(url: string, data?: unknown) { +export function apiPost(url: string, data?: unknown, options?: RequestOptions) { return request({ method: 'POST', url, data: data as Record, + ...options, }) } -export function apiPut(url: string, data?: unknown) { +export function apiPut(url: string, data?: unknown, options?: RequestOptions) { return request({ method: 'PUT', url, data: data as Record, + ...options, }) } -export function apiPatch(url: string, data?: unknown) { +export function apiPatch(url: string, data?: unknown, options?: RequestOptions) { return request({ method: 'PATCH', url, data: data as Record, + ...options, }) } diff --git a/apps/frontend/src/services/admin/cost-center.ts b/apps/frontend/src/services/admin/cost-center.ts index 0882f669..4b9313bf 100644 --- a/apps/frontend/src/services/admin/cost-center.ts +++ b/apps/frontend/src/services/admin/cost-center.ts @@ -51,6 +51,7 @@ export function applyAdminTemplateProductBootstrap() { return apiPost( '/api/v1/admin/cost-center/template-bootstrap/apply', { repair: true }, + { timeout: 300_000 }, ) } @@ -160,7 +161,7 @@ export function syncAdminAffiliateDashCostSnapshots() { insertedCount: number batchCount: number } - }>('/api/v1/admin/cost-center/affiliate-products/sync-snapshots') + }>('/api/v1/admin/cost-center/affiliate-products/sync-snapshots', {}, { timeout: 300_000 }) } @@ -233,7 +234,7 @@ export function backfillAdminProductMappings(payload: Record) { limit: number batches: number remainingCount: number - }>('/api/v1/admin/cost-center/mappings/backfill', payload) + }>('/api/v1/admin/cost-center/mappings/backfill', payload, { timeout: 300_000 }) } export function backfillAdminNormalizedQuantities(payload: Record) { @@ -242,7 +243,7 @@ export function backfillAdminNormalizedQuantities(payload: Record('/api/v1/admin/cost-center/normalized-quantities/backfill', payload) + }>('/api/v1/admin/cost-center/normalized-quantities/backfill', payload, { timeout: 300_000 }) } export function fetchAdminCostItems(params?: Record) {