fix(提示语): 失败提示优先展示后端真实原因,修正 10+ 处误导文案
上架/删除品牌/去重/转换/拆分/撤回/查ASIN/产品风险/跟价/巡店/店铺匹配/视频工作台: - 解析失败不再只报通用文案,逐条展示后端文件级 errorMessage(上架新增「店铺未找到」专属弹窗) - 匹配失败不再一律「请检查店铺名」,按 matchStatus 区分 CONFLICT/PENDING - 去重/转换/拆分全失败弹窗优先列各文件真实原因,取不到才回退猜测文案 - dispatch-guard 新增 fileErrors 选项与 collectDistinctErrors 导出
This commit is contained in:
@@ -267,6 +267,13 @@ export interface ParseResultOptions {
|
||||
requireRows?: boolean
|
||||
/** 必要字段名,用于拼「缺什么」的提示,如 'ASIN / 国家' */
|
||||
requiredColumnsHint?: string
|
||||
/**
|
||||
* 文件级失败原因(后端 files[].errorMessage)。0 有效行时优先展示这些具体
|
||||
* 原因:店铺未录入、表头不匹配等都会让文件级解析提前失败,totalRows 同样是
|
||||
* 0,只报通用「空文件」文案会把用户引向错误的排查方向(2026-09-17 用户因
|
||||
* 「店铺未录入」被误导反复重传同一个 Excel,连试 7 次)。
|
||||
*/
|
||||
fileErrors?: readonly string[]
|
||||
title?: string
|
||||
}
|
||||
|
||||
@@ -333,7 +340,21 @@ export function checkParseResult(
|
||||
: ''
|
||||
|
||||
if (requireRows && acceptedRows === 0) {
|
||||
if (!totalRows) {
|
||||
const fileErrors = collectDistinctErrors(options.fileErrors)
|
||||
if (fileErrors.length) {
|
||||
const shown = fileErrors.slice(0, 8)
|
||||
issues.push({
|
||||
code: 'parse.file-failed',
|
||||
severity: 'block',
|
||||
message:
|
||||
'以下文件解析未通过,没有可执行的数据行:\n' +
|
||||
shown.map((item) => `· ${item}`).join('\n') +
|
||||
(fileErrors.length > shown.length
|
||||
? `\n· 另有 ${fileErrors.length - shown.length} 条不同原因`
|
||||
: '') +
|
||||
'\n请按上述原因处理对应文件后重新上传解析。',
|
||||
})
|
||||
} else if (!totalRows) {
|
||||
issues.push({
|
||||
code: 'parse.empty-file',
|
||||
severity: 'block',
|
||||
@@ -387,6 +408,20 @@ function normalizeCount(value: unknown): number | null {
|
||||
return null
|
||||
}
|
||||
|
||||
/** 汇总一组错误原因:去空、去重(同一原因多条只留一条),保持出现顺序。 */
|
||||
export function collectDistinctErrors(values: readonly unknown[] | undefined): string[] {
|
||||
if (!values || !values.length) return []
|
||||
const seen = new Set<string>()
|
||||
const result: string[] = []
|
||||
for (const value of values) {
|
||||
const trimmed = typeof value === 'string' ? value.trim() : ''
|
||||
if (!trimmed || seen.has(trimmed)) continue
|
||||
seen.add(trimmed)
|
||||
result.push(trimmed)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
export interface QueuePayloadOptions {
|
||||
/** data 下必须存在且非空的字段名 */
|
||||
requiredDataKeys?: readonly string[]
|
||||
|
||||
Reference in New Issue
Block a user