Add openExternal IPC handler and integrate with UI components
- Introduce `openExternal` IPC handler in `electron/main.ts` for opening external links via the default browser or native app. - Update typings in `electron.d.ts` and `preload.ts` to include `openExternal`. - Refactor `ComposerRightBar` and `LeftBar` components to leverage `electron.openExternal` for external link actions (e.g., Facebook, Discord). - Add offline mode logic to filter navigation options in `ComposerRightBar` and `LeftBar`. - Enhance footer bar to display book titles when chapters are unavailable.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {app, BrowserWindow, ipcMain, nativeImage, protocol, safeStorage} from 'electron';
|
||||
import {app, BrowserWindow, ipcMain, nativeImage, protocol, safeStorage, shell} from 'electron';
|
||||
import * as path from 'path';
|
||||
import {fileURLToPath} from 'url';
|
||||
import * as fs from 'fs';
|
||||
@@ -116,6 +116,11 @@ function createMainWindow(): void {
|
||||
});
|
||||
}
|
||||
|
||||
// IPC Handler pour ouvrir des liens externes (navigateur/app native)
|
||||
ipcMain.handle('open-external', async (_event, url: string) => {
|
||||
await shell.openExternal(url);
|
||||
});
|
||||
|
||||
// IPC Handlers pour la gestion du token (OS-encrypted storage)
|
||||
ipcMain.handle('get-token', () => {
|
||||
const storage:SecureStorage = getSecureStorage();
|
||||
|
||||
@@ -35,6 +35,9 @@ contextBridge.exposeInMainWorld('electron', {
|
||||
// Database initialization (shortcut for convenience)
|
||||
dbInitialize: (userId: string, encryptionKey: string) => ipcRenderer.invoke('db-initialize', userId, encryptionKey),
|
||||
|
||||
// Open external links (browser/native app)
|
||||
openExternal: (url: string) => ipcRenderer.invoke('open-external', url),
|
||||
|
||||
// Offline mode management
|
||||
offlinePinSet: (pin: string) => ipcRenderer.invoke('offline:pin:set', { pin }),
|
||||
offlinePinVerify: (pin: string) => ipcRenderer.invoke('offline:pin:verify', { pin }),
|
||||
|
||||
Reference in New Issue
Block a user