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

@@ -0,0 +1,45 @@
/**
* Zod schemas for Authentication module validation
*/
import { z } from 'zod'
/**
* Schema for login request validation
*/
export const LoginRequestSchema = z.object({
username: z.string().min(1, 'Username is required'),
password: z.string().min(1, 'Password is required')
})
export type LoginRequestZod = z.infer<typeof LoginRequestSchema>
/**
* Schema for user info validation
*/
export const UserInfoSchema = z.object({
id: z.number().int().positive(),
username: z.string().min(1),
userType: z.enum(['Admin', 'User', 'Guest']),
computerName: z.string().optional()
})
export type UserInfoZod = z.infer<typeof UserInfoSchema>
/**
* Validate login request
*/
export function validateLoginRequest(input: unknown): {
success: boolean
data?: LoginRequestZod
error?: string
} {
const result = LoginRequestSchema.safeParse(input)
if (result.success) {
return { success: true, data: result.data }
}
return {
success: false,
error: result.error.issues.map((e) => `${e.path.join('.')}: ${e.message}`).join('; ')
}
}