task-125(记录与版本中心): 实现历史记录空/错状态

新增 history-feedback.ts:历史空态文案与错误归一。

TDD: task-125.test.ts 8 用例 RED→GREEN。
This commit is contained in:
2026-09-05 17:32:48 +08:00
parent d8950e93da
commit 4731c9a23c
2 changed files with 59 additions and 0 deletions
@@ -0,0 +1,13 @@
/** 历史记录列表空/错误反馈(任务 125):空态文案与请求错误归一;纯逻辑。 */
import { requestErrorMessage } from '../../api/envelope.ts'
export function historyEmptyText(input: { hasFilter: boolean; total: number }): string {
if (typeof input.total === 'number' && input.total > 0) return ''
return input.hasFilter ? '暂无符合条件的生成记录,请调整筛选条件' : '暂无生成记录'
}
/** 请求失败归一为可展示文案,空则回兜底。 */
export function historyErrorText(error: unknown): string {
const message = requestErrorMessage(error)
return message.trim() || '加载失败,请稍后重试'
}