task-145: 前端可下载判定契约(fileReady/downloadUrl/终态 SUCCESS+FAILED 可下载,PENDING/RUNNING/无 resultId 不可下载)+ 8 条测试
This commit is contained in:
@@ -17,13 +17,20 @@ export const FILE_PROGRESS_KEYS = [
|
||||
export interface DownloadableItem {
|
||||
resultId?: number | null
|
||||
fileReady?: boolean | null
|
||||
fileStatus?: string | null
|
||||
downloadUrl?: string | null
|
||||
}
|
||||
|
||||
/** 可下载判定:有结果记录且文件已就绪(fileReady 或 downloadUrl 非空)。 */
|
||||
/**
|
||||
* 可下载判定(Task 145):有结果记录,且满足其一——
|
||||
* fileReady=true、downloadUrl 非空、fileStatus 为终态(SUCCESS 可下载结果文件,
|
||||
* FAILED 可下载错误文件或用于展示错误)。
|
||||
*/
|
||||
export function canDownloadItem(item: DownloadableItem | null | undefined): boolean {
|
||||
if (!item) return false
|
||||
return Boolean(item.resultId && (item.fileReady || item.downloadUrl))
|
||||
const ready = item.fileReady || Boolean(item.downloadUrl)
|
||||
const terminalStatus = item.fileStatus === 'SUCCESS' || item.fileStatus === 'FAILED'
|
||||
return Boolean(item.resultId && (ready || terminalStatus))
|
||||
}
|
||||
|
||||
/** 有效进度值:仅 fileProgressPercent 需要严格 >0,其余字段非空即可(0 是合法计数)。 */
|
||||
|
||||
Reference in New Issue
Block a user