fix(frontend): 对齐数据任务详情状态
This commit is contained in:
13
frontend/src/utils/dataProcessStatus.d.ts
vendored
Normal file
13
frontend/src/utils/dataProcessStatus.d.ts
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import type { DataProcessStatus } from '@/types/dataProcess'
|
||||
|
||||
export type DataProcessStatusTagType = 'primary' | 'success' | 'warning' | 'danger' | 'info'
|
||||
|
||||
export interface DataProcessStatusLike {
|
||||
status?: DataProcessStatus
|
||||
output_dataset_id?: string | number | null
|
||||
}
|
||||
|
||||
export function dataProcessDisplayStatus(task: DataProcessStatusLike): {
|
||||
label: string
|
||||
type: DataProcessStatusTagType
|
||||
}
|
||||
18
frontend/src/utils/dataProcessStatus.js
Normal file
18
frontend/src/utils/dataProcessStatus.js
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* 将数据处理任务的执行状态与当前轮发布指针合并为用户可理解的状态。
|
||||
* 上一轮保留的 output_datasets 不参与判断,避免将尚未重新发布的当前轮误标为已发布。
|
||||
*
|
||||
* @param {{ status?: string, output_dataset_id?: string | number | null }} task
|
||||
* @returns {{ label: string, type: 'primary' | 'success' | 'warning' | 'danger' | 'info' }}
|
||||
*/
|
||||
export function dataProcessDisplayStatus(task) {
|
||||
if (task.status === 'running') return { label: '生成中', type: 'primary' }
|
||||
if (task.status === 'completed') {
|
||||
return task.output_dataset_id
|
||||
? { label: '已发布', type: 'success' }
|
||||
: { label: '已生成', type: 'warning' }
|
||||
}
|
||||
if (task.status === 'failed') return { label: '生成失败', type: 'danger' }
|
||||
if (task.status === 'stopped') return { label: '已停止', type: 'info' }
|
||||
return { label: '待生成', type: 'info' }
|
||||
}
|
||||
Reference in New Issue
Block a user