diff --git a/web/src/utils/helpers.ts b/web/src/utils/helpers.ts index 4fff27e..c0d930d 100644 --- a/web/src/utils/helpers.ts +++ b/web/src/utils/helpers.ts @@ -7,13 +7,17 @@ export function dateTime(value?: string | number | null): string { // 对齐归档版 conflictMessage:优先后端 error 字段;409/503 冲突类错误即使无 hint 也直接透出后端 // 分类文案(如「该竞品正在同步中」),避免接口报错时界面无任何反馈。 +// 409 时若后端附带 reason_code(如 start/resume 的就绪原因),追加展示帮助定位。 export function conflictMessage(error: any, conflictHint?: string): string { const status = error?.status ?? error?.body?.status; const message = error?.message || error?.body?.error || '请求失败'; - if (status === 409 && conflictHint) return `${message}:${conflictHint}`; + const reason = error?.body?.reason_code; + if (status === 409 && conflictHint) return reason ? `${message}:${conflictHint}(${reason})` : `${message}:${conflictHint}`; if ((status === 409 || status === 503) && message === '请求失败') { - return conflictHint ? conflictHint : `请求失败(${status}),请稍后重试`; + if (conflictHint) return reason ? `${conflictHint}(${reason})` : conflictHint; + return reason ? `请求失败(409,${reason}),请稍后重试` : `请求失败(${status}),请稍后重试`; } + if (reason && status === 409) return `${message}(${reason})`; return message; }