Feat: Add real-time progress and logging to data extractor

- Implement IPC event system for pushing progress updates from main to renderer
- Add Zustand store for centralized extractor state management
- Refactor useExtractor hook to use store pattern
- Add chromium-bidi dependency and externalize Playwright for build compatibility
- Show detailed logs during extraction (DB connection, order resolution, ERP login, data import)
This commit is contained in:
Misaka
2026-03-04 20:51:54 +08:00
parent fed76b4fe0
commit 9e1b5530ea
12 changed files with 297 additions and 55 deletions

View File

@@ -1,9 +1,12 @@
import type { ErpSession } from './erp.types'
export type LogLevel = 'info' | 'success' | 'warning' | 'error' | 'system'
export interface ExtractorInput {
orderNumbers: string[]
batchSize?: number
onProgress?: (message: string, progress: number) => void
onLog?: (level: LogLevel, message: string) => void
}
/**

View File

@@ -77,6 +77,18 @@ export interface ExtractorAPI {
runExtractor: (
input: ExtractorInput
) => Promise<{ success: boolean; data?: ExtractorResult; error?: string }>
/**
* Subscribe to progress updates
* @param callback - Callback function receiving progress data
* @returns Unsubscribe function
*/
onProgress: (callback: (data: { message: string; progress: number }) => void) => () => void
/**
* Subscribe to log messages
* @param callback - Callback function receiving log data
* @returns Unsubscribe function
*/
onLog: (callback: (data: { level: string; message: string }) => void) => () => void
}
/**