fix(frontend): 支持请求级自定义超时并将接单模板初始化与批量回填超时延长至5分钟
- 在 http 客户端封装中增加可选 RequestOptions 参数透传,允许对耗时较长的数据初始化/大批量回填接口单独配置超时 - 将 applyAdminTemplateProductBootstrap、syncAdminAffiliateDashCostSnapshots、backfillAdminProductMappings 及 backfillAdminNormalizedQuantities 客户端超时由 50 秒延长至 300 秒(5分钟) - 彻底解决生产全量订单数据规模下接单模板初始化触发 50 秒网络超时提示的问题 - 验证方式:npm --prefix apps/frontend run typecheck 通过,生产镜像构建运行正常
This commit is contained in:
@@ -182,40 +182,46 @@ function request<T>(config: Parameters<typeof http.request<ApiEnvelope<T>>>[0])
|
||||
return http.request<ApiEnvelope<T>, ApiEnvelope<T>>(config)
|
||||
}
|
||||
|
||||
export function apiGet<T>(url: string, params?: Record<string, unknown>) {
|
||||
return request<T>({ method: 'GET', url, params })
|
||||
type RequestOptions = Partial<Parameters<typeof http.request>[0]>
|
||||
|
||||
export function apiGet<T>(url: string, params?: Record<string, unknown>, options?: RequestOptions) {
|
||||
return request<T>({ method: 'GET', url, params, ...options })
|
||||
}
|
||||
|
||||
export function apiGetBlob(url: string, params?: Record<string, unknown>) {
|
||||
export function apiGetBlob(url: string, params?: Record<string, unknown>, options?: RequestOptions) {
|
||||
return http.request<Blob, Blob>({
|
||||
method: 'GET',
|
||||
url,
|
||||
params,
|
||||
responseType: 'blob',
|
||||
...options,
|
||||
})
|
||||
}
|
||||
|
||||
export function apiPost<T>(url: string, data?: unknown) {
|
||||
export function apiPost<T>(url: string, data?: unknown, options?: RequestOptions) {
|
||||
return request<T>({
|
||||
method: 'POST',
|
||||
url,
|
||||
data: data as Record<string, unknown>,
|
||||
...options,
|
||||
})
|
||||
}
|
||||
|
||||
export function apiPut<T>(url: string, data?: unknown) {
|
||||
export function apiPut<T>(url: string, data?: unknown, options?: RequestOptions) {
|
||||
return request<T>({
|
||||
method: 'PUT',
|
||||
url,
|
||||
data: data as Record<string, unknown>,
|
||||
...options,
|
||||
})
|
||||
}
|
||||
|
||||
export function apiPatch<T>(url: string, data?: unknown) {
|
||||
export function apiPatch<T>(url: string, data?: unknown, options?: RequestOptions) {
|
||||
return request<T>({
|
||||
method: 'PATCH',
|
||||
url,
|
||||
data: data as Record<string, unknown>,
|
||||
...options,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ export function applyAdminTemplateProductBootstrap() {
|
||||
return apiPost<TemplateProductBootstrapResult>(
|
||||
'/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<string, unknown>) {
|
||||
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<string, unknown>) {
|
||||
@@ -242,7 +243,7 @@ export function backfillAdminNormalizedQuantities(payload: Record<string, unknow
|
||||
limit: number
|
||||
batches: number
|
||||
remainingCount: number
|
||||
}>('/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<string, unknown>) {
|
||||
|
||||
Reference in New Issue
Block a user