feat: add progress indicator to cleaner execution report dialog

- Add CleanerProgress type for tracking execution progress
- Implement progress calculation: (1 + i + j/Mᵢ)/(1+N) × 100
  - Login complete: 1/(1+N) × 100
  - Per material: (1 + orderIndex + materialIdx/totalMaterials)/(1+totalOrders) × 100
- Add cleaner.onProgress IPC event for real-time progress updates
- Enhance ExecutionReportDialog with progress bar and status display
- Update useCleaner hook with progress state management
- Dialog opens immediately on execution start, showing progress then results
This commit is contained in:
Misaka_Company
2026-03-05 13:25:04 +08:00
parent 921ca15be6
commit dc01896d8b
8 changed files with 481 additions and 133 deletions

View File

@@ -2,7 +2,7 @@ import { contextBridge, ipcRenderer } from 'electron'
import { electronAPI } from '@electron-toolkit/preload'
import type { MySqlConfig, SqlServerConfig } from '../main/types/ipc-api.types'
import type { ExtractorInput, ExtractionProgress } from '../main/types/extractor.types'
import type { CleanerInput, ExportResultItem } from '../main/types/cleaner.types'
import type { CleanerInput, CleanerProgress, ExportResultItem } from '../main/types/cleaner.types'
import type { ResolverInput } from '../main/ipc/resolver-handler'
import type { LoginRequest } from '../main/ipc/auth-handler'
import type { UserInfo } from '../main/types/user.types'
@@ -47,7 +47,14 @@ const api = {
// Cleaner service
cleaner: {
runCleaner: (input: CleanerInput) => ipcRenderer.invoke('cleaner:run', input),
exportResults: (items: ExportResultItem[]) => ipcRenderer.invoke('cleaner:exportResults', items)
exportResults: (items: ExportResultItem[]) =>
ipcRenderer.invoke('cleaner:exportResults', items),
onProgress: (callback: (data: CleanerProgress) => void) => {
const subscription = (_event: Electron.IpcRendererEvent, data: CleanerProgress) =>
callback(data)
ipcRenderer.on('cleaner:progress', subscription)
return () => ipcRenderer.removeListener('cleaner:progress', subscription)
}
},
// Order number resolver