feat: add TypeORM, logger, schemas, hooks and stores

- Add TypeORM integration with data-source, entities and repositories
- Add logger service for structured logging
- Add Zod validation schemas for auth, cleaner and extractor
- Add custom React hooks (useAuth, useCleaner, useExtractor, useValidation)
- Add Zustand stores (useAppStore, useUserStore)
- Add UI components (Button, Modal, Toast)
- Add error types and ErpBrowserManager
- Refactor IPC handlers and services
- Add unit tests for new modules

Co-Authored-By: Claude (glm-5) <noreply@anthropic.com>
This commit is contained in:
Misaka
2026-03-02 23:10:15 +08:00
parent 982fb8fde6
commit a05c8a9037
57 changed files with 5150 additions and 974 deletions

View File

@@ -1,6 +1,9 @@
import { ipcMain } from 'electron'
import * as fs from 'fs/promises'
import * as path from 'path'
import { createLogger } from '../services/logger'
const log = createLogger('FileHandler')
/**
* Register IPC handlers for file operations
@@ -9,9 +12,11 @@ export function registerFileHandlers(): void {
// Read file content
ipcMain.handle('file:read', async (_event, filePath: string): Promise<string> => {
try {
log.debug('Reading file', { filePath })
return await fs.readFile(filePath, 'utf-8')
} catch (error) {
const message = error instanceof Error ? error.message : 'Failed to read file'
log.error('Failed to read file', { filePath, error: message })
throw new Error(message)
}
})
@@ -19,12 +24,14 @@ export function registerFileHandlers(): void {
// Write content to file
ipcMain.handle('file:write', async (_event, filePath: string, content: string): Promise<void> => {
try {
log.debug('Writing file', { filePath })
// Ensure directory exists
const dir = path.dirname(filePath)
await fs.mkdir(dir, { recursive: true })
await fs.writeFile(filePath, content, 'utf-8')
} catch (error) {
const message = error instanceof Error ? error.message : 'Failed to write file'
log.error('Failed to write file', { filePath, error: message })
throw new Error(message)
}
})
@@ -42,6 +49,7 @@ export function registerFileHandlers(): void {
// List files in directory
ipcMain.handle('file:list', async (_event, dirPath: string): Promise<string[]> => {
try {
log.debug('Listing directory', { dirPath })
const entries = await fs.readdir(dirPath, { withFileTypes: true })
return entries
.filter((entry) => entry.isFile())
@@ -49,6 +57,7 @@ export function registerFileHandlers(): void {
.sort()
} catch (error) {
const message = error instanceof Error ? error.message : 'Failed to list directory'
log.error('Failed to list directory', { dirPath, error: message })
throw new Error(message)
}
})