Feat: Add segmented progress bar for data extractor with dynamic phase calculation

- Add ExtractionProgress type with phase, batch, and subProgress fields
- Implement dynamic progress calculation: 1 (login) + N (batches) + 2 (merge/import)
- Create SegmentedProgressBar component with 4 colored phases (purple/blue/amber/green)
- Show batch-level progress during download phase (e.g., 批次 1/10)
- Display sub-progress during login phase (连接数据库/解析订单号/登录 ERP)
- Update IPC handler and extractor services to report detailed progress
- Add phase status indicators (completed/active/pending) with color-coded dots
This commit is contained in:
Misaka
2026-03-04 22:16:47 +08:00
parent 4494351e52
commit 2dea1f9556
11 changed files with 299 additions and 46 deletions

View File

@@ -2,10 +2,25 @@ import type { ErpSession } from './erp.types'
export type LogLevel = 'info' | 'success' | 'warning' | 'error' | 'system'
export type ExtractionPhase = 'login' | 'downloading' | 'merging' | 'importing'
export interface ExtractionProgress {
message: string
progress: number
phase?: ExtractionPhase
currentBatch?: number
totalBatches?: number
subProgress?: {
step: string
current: number
total: number
}
}
export interface ExtractorInput {
orderNumbers: string[]
batchSize?: number
onProgress?: (message: string, progress: number) => void
onProgress?: (message: string, progress: number, extra?: Partial<ExtractionProgress>) => void
onLog?: (level: LogLevel, message: string) => void
}
@@ -43,7 +58,7 @@ export interface ExtractorCoreInput {
orderNumbers: string[]
downloadDir: string
batchSize: number
onProgress?: (message: string, progress: number) => void
onProgress?: (message: string, progress: number, extra?: Partial<ExtractionProgress>) => void
}
/**

View File

@@ -3,7 +3,7 @@
* These types define the API exposed to the renderer process via contextBridge
*/
import type { ExtractorInput, ExtractorResult } from './extractor.types'
import type { ExtractorInput, ExtractorResult, ExtractionProgress } from './extractor.types'
import type {
CleanerInput,
CleanerResult,
@@ -82,7 +82,7 @@ export interface ExtractorAPI {
* @param callback - Callback function receiving progress data
* @returns Unsubscribe function
*/
onProgress: (callback: (data: { message: string; progress: number }) => void) => () => void
onProgress: (callback: (data: ExtractionProgress) => void) => () => void
/**
* Subscribe to log messages
* @param callback - Callback function receiving log data