修复: taskStatusLabel旧态映射防老DB状态报错

This commit is contained in:
2026-06-17 14:38:19 +08:00
parent 924158cff2
commit 1cd7652a34

View File

@@ -83,12 +83,23 @@ export const TASK_STATUS_CLASS: Record<string, string> = {
cancelled: 'status-abandoned',
}
// D-260616-01 删旧 5 态前的老 DB 数据兼容映射(老 DB 可能存 completed/review_ready/merged/abandoned)
// 新 DB 经 TaskStatus::is_valid 拦截不会有,但老 DB 未迁移清理时兜底显示而非 $t() 报错
const LEGACY_STATUS_MAP: Record<string, string> = {
completed: 'done',
review_ready: 'in_review',
merged: 'done',
abandoned: 'cancelled',
}
export function taskStatusLabel(status: string): string {
return TASK_STATUS_LABELS[status] ?? status
const mapped = LEGACY_STATUS_MAP[status] ?? status
return TASK_STATUS_LABELS[mapped] ?? 'tasks.status.todo'
}
export function taskStatusClass(status: string): string {
return TASK_STATUS_CLASS[status] ?? 'status-todo'
const mapped = LEGACY_STATUS_MAP[status] ?? status
return TASK_STATUS_CLASS[mapped] ?? 'status-todo'
}
// ── 任务优先级 ──