Remove DataService and OfflineDataService, refactor book and character operations to use streamlined handlers in LocalSystem
- Delete `data.service.ts` and `offline-data.service.ts`, consolidating functionality into `LocalSystem`. - Refactor book, character, and conversation operations to adopt unified, multilingual, and session-enabled IPC handlers in `LocalSystem`. - Simplify redundant legacy methods, enhancing maintainability and consistency.
This commit is contained in:
@@ -1,36 +1,34 @@
|
||||
const { contextBridge, ipcRenderer } = require('electron');
|
||||
|
||||
// Exposer des APIs sécurisées au renderer process
|
||||
/**
|
||||
* Exposer des APIs sécurisées au renderer process
|
||||
* Utilise invoke() générique pour tous les appels IPC
|
||||
*/
|
||||
contextBridge.exposeInMainWorld('electron', {
|
||||
// Platform info
|
||||
platform: process.platform,
|
||||
|
||||
// Token management
|
||||
// Generic invoke method - use this for all IPC calls
|
||||
invoke: (channel: string, ...args: any[]) => ipcRenderer.invoke(channel, ...args),
|
||||
|
||||
// Token management (shortcuts for convenience)
|
||||
getToken: () => ipcRenderer.invoke('get-token'),
|
||||
setToken: (token: string) => ipcRenderer.invoke('set-token', token),
|
||||
removeToken: () => ipcRenderer.invoke('remove-token'),
|
||||
|
||||
// Language management
|
||||
// Language management (shortcuts for convenience)
|
||||
getLang: () => ipcRenderer.invoke('get-lang'),
|
||||
setLang: (lang: 'fr' | 'en') => ipcRenderer.invoke('set-lang', lang),
|
||||
|
||||
// Auth events
|
||||
// Auth events (use send for one-way communication)
|
||||
loginSuccess: (token: string, userId: string) => ipcRenderer.send('login-success', token, userId),
|
||||
logout: () => ipcRenderer.send('logout'),
|
||||
|
||||
// Database operations
|
||||
// Encryption key management (shortcuts for convenience)
|
||||
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),
|
||||
|
||||
// Database initialization (shortcut for convenience)
|
||||
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