diff --git a/src/store.ts b/src/store.ts index ec85fb5..19663c5 100644 --- a/src/store.ts +++ b/src/store.ts @@ -84,9 +84,50 @@ export interface PipelineStage { export interface PipelineStats { overall_progress: number + current_phase?: string | null stages: PipelineStage[] } +// Pipeline Phases 配置 +export interface PhaseProcessor { + name: string + weight: number + depends_on?: string[] +} + +export interface PipelinePhase { + name: string + weight: number + processors: PhaseProcessor[] +} + +export interface PipelinePhasesConfig { + phases: PipelinePhase[] +} + +// Pipeline Progress API (new) +export interface ProcessorProgressDetail { + name: string + status: 'pending' | 'running' | 'completed' | 'failed' + progress: number + message?: string +} + +export interface PhaseProgressDetail { + status: string + progress: number + processors: Record +} + +export interface FileProgressDetail { + file_uuid: string + overall_progress: number + current_phase: string | null + phases: Record +} + +export const pipelinePhasesCache = ref(null) + export interface SystemStats { cpu_used_percent: number memory_used_percent: number @@ -991,6 +1032,43 @@ export async function syncAllProcessingFiles(): Promise { } } +export async function loadPipelinePhases(force = false): Promise { + if (!force && pipelinePhasesCache.value) return pipelinePhasesCache.value + + try { + const resp = await fetch('/api/v1/pipeline/phases') + if (!resp.ok) { + console.warn('Pipeline phases API failed:', resp.status) + return null + } + + const data: PipelinePhasesConfig = await resp.json() + pipelinePhasesCache.value = data + return data + } catch (e) { + console.error('loadPipelinePhases failed:', e) + return null + } +} + +export async function loadFileProgress(fileUuid: string): Promise { + if (!fileUuid) return null + + try { + const resp = await fetch(`/api/v1/file/${fileUuid}/progress`) + if (!resp.ok) { + console.warn('File progress API failed:', resp.status) + return null + } + + const data: FileProgressDetail = await resp.json() + return data + } catch (e) { + console.error('loadFileProgress failed:', e) + return null + } +} + export async function loadPipelineStats(fileUuid: string, force = false): Promise { if (!fileUuid) return null if (!force && pipelineStatsCache.value[fileUuid]) return pipelineStatsCache.value[fileUuid] @@ -998,6 +1076,38 @@ export async function loadPipelineStats(fileUuid: string, force = false): Promis loadingPipelineStats.add(fileUuid) try { + // Try new progress API first + const progressData = await loadFileProgress(fileUuid) + if (progressData && progressData.overall_progress !== undefined) { + const stages: PipelineStage[] = [] + + // Convert phases to stages + if (progressData.phases) { + const phasesConfig = await loadPipelinePhases() + const phaseWeights = phasesConfig?.phases || [] + + for (const [phaseName, phaseData] of Object.entries(progressData.phases)) { + const config = phaseWeights.find(p => p.name === phaseName) + stages.push({ + name: phaseName, + weight: config?.weight || 0.1, + progress: phaseData.progress || 0, + status: phaseData.status as any || 'pending' + }) + } + } + + const pipelineStats: PipelineStats = { + overall_progress: progressData.overall_progress, + current_phase: progressData.current_phase, + stages + } + + pipelineStatsCache.value = { ...pipelineStatsCache.value, [fileUuid]: pipelineStats } + return pipelineStats + } + + // Fallback to old API const data: any = await apiCall('get_pipeline_stats', { fileUuid }) const stages = data.stages || []