Integrate local database management and IPC handlers into Electron

- Add comprehensive IPC handlers for database operations like books, chapters, characters, and conversations.
- Implement local database initialization and user data encryption.
- Update preload script paths for consistent environment handling.
- Modify `page.tsx` to initialize local database within Electron environment.
- Add new dependencies including `node-sqlite3-wasm` and `electron-rebuild`.
This commit is contained in:
natreex
2025-11-17 07:46:20 -05:00
parent b4eafca3bc
commit 71067c6fa8
10 changed files with 820 additions and 13 deletions

17
electron.d.ts vendored
View File

@@ -5,6 +5,23 @@ export interface IElectronAPI {
removeToken: () => Promise<boolean>;
loginSuccess: (token: string) => void;
logout: () => void;
// Database operations
generateEncryptionKey: (userId: string) => Promise<{ success: boolean; key?: string; error?: string }>;
getUserEncryptionKey: (userId: string) => Promise<string | null>;
setUserEncryptionKey: (userId: string, encryptionKey: string) => Promise<boolean>;
dbInitialize: (userId: string, encryptionKey: string) => Promise<{ success: boolean; error?: string }>;
dbGetBooks: () => Promise<{ success: boolean; data?: any[]; error?: string }>;
dbGetBook: (bookId: string) => Promise<{ success: boolean; data?: any; error?: string }>;
dbSaveBook: (book: any, authorId?: string) => Promise<{ success: boolean; error?: string }>;
dbDeleteBook: (bookId: string) => Promise<{ success: boolean; error?: string }>;
dbSaveChapter: (chapter: any, bookId: string, contentId?: string) => Promise<{ success: boolean; error?: string }>;
dbGetCharacters: (bookId: string) => Promise<{ success: boolean; data?: any[]; error?: string }>;
dbSaveCharacter: (character: any, bookId: string) => Promise<{ success: boolean; error?: string }>;
dbGetConversations: (bookId: string) => Promise<{ success: boolean; data?: any[]; error?: string }>;
dbSaveConversation: (conversation: any, bookId: string) => Promise<{ success: boolean; error?: string }>;
dbGetSyncStatus: () => Promise<{ success: boolean; data?: any[]; error?: string }>;
dbGetPendingChanges: (limit?: number) => Promise<{ success: boolean; data?: any[]; error?: string }>;
}
declare global {