feat: implement IPC handlers, database services and Extractor UI

- Add SqlServerService and MySqlService for database persistence
- Implement IPC handlers for file, extractor, cleaner, and database operations
- Define IPC API types and update preload script
- Create ExtractorPage UI with OrderNumberInput component
- Add unit and integration tests for MySQL and SQL Server
- Update vitest config with path aliases
This commit is contained in:
Misaka
2026-03-01 15:46:01 +08:00
parent c39e1504aa
commit 5760b56f70
23 changed files with 2156 additions and 33 deletions

View File

@@ -0,0 +1,49 @@
import { ipcMain } from 'electron'
import { ErpAuthService } from '../services/erp/erp-auth'
import { CleanerService } from '../services/erp/cleaner'
import type { CleanerInput, CleanerResult } from '../types/cleaner.types'
/**
* Register IPC handlers for cleaner service
*/
export function registerCleanerHandlers(): void {
ipcMain.handle(
'cleaner:run',
async (
_event,
input: CleanerInput
): Promise<{ success: boolean; data?: CleanerResult; error?: string }> => {
let authService: ErpAuthService | null = null
try {
// Create auth service and login
authService = new ErpAuthService({
url: process.env.ERP_URL || '',
username: process.env.ERP_USERNAME || '',
password: process.env.ERP_PASSWORD || '',
headless: true
})
await authService.login()
// Create cleaner service and run cleaning
const cleaner = new CleanerService(authService)
const result = await cleaner.clean(input)
return { success: true, data: result }
} catch (error) {
const message = error instanceof Error ? error.message : 'Unknown error'
return { success: false, error: message }
} finally {
// Clean up: close browser
if (authService) {
try {
await authService.close()
} catch {
// Ignore cleanup errors
}
}
}
}
)
}