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:
@@ -12,4 +12,21 @@ contextBridge.exposeInMainWorld('electron', {
|
||||
// Auth events
|
||||
loginSuccess: (token: string) => ipcRenderer.send('login-success', token),
|
||||
logout: () => ipcRenderer.send('logout'),
|
||||
|
||||
// Database operations
|
||||
generateEncryptionKey: (userId: string) => ipcRenderer.invoke('generate-encryption-key', userId),
|
||||
getUserEncryptionKey: (userId: string) => ipcRenderer.invoke('get-user-encryption-key', userId),
|
||||
setUserEncryptionKey: (userId: string, encryptionKey: string) => ipcRenderer.invoke('set-user-encryption-key', userId, encryptionKey),
|
||||
dbInitialize: (userId: string, encryptionKey: string) => ipcRenderer.invoke('db-initialize', userId, encryptionKey),
|
||||
dbGetBooks: () => ipcRenderer.invoke('db-get-books'),
|
||||
dbGetBook: (bookId: string) => ipcRenderer.invoke('db-get-book', bookId),
|
||||
dbSaveBook: (book: any, authorId?: string) => ipcRenderer.invoke('db-save-book', book, authorId),
|
||||
dbDeleteBook: (bookId: string) => ipcRenderer.invoke('db-delete-book', bookId),
|
||||
dbSaveChapter: (chapter: any, bookId: string, contentId?: string) => ipcRenderer.invoke('db-save-chapter', chapter, bookId, contentId),
|
||||
dbGetCharacters: (bookId: string) => ipcRenderer.invoke('db-get-characters', bookId),
|
||||
dbSaveCharacter: (character: any, bookId: string) => ipcRenderer.invoke('db-save-character', character, bookId),
|
||||
dbGetConversations: (bookId: string) => ipcRenderer.invoke('db-get-conversations', bookId),
|
||||
dbSaveConversation: (conversation: any, bookId: string) => ipcRenderer.invoke('db-save-conversation', conversation, bookId),
|
||||
dbGetSyncStatus: () => ipcRenderer.invoke('db-get-sync-status'),
|
||||
dbGetPendingChanges: (limit?: number) => ipcRenderer.invoke('db-get-pending-changes', limit),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user