-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreload.js
More file actions
16 lines (12 loc) · 883 Bytes
/
preload.js
File metadata and controls
16 lines (12 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('electronAPI', {
// Existing examples (can be kept or removed if not used by your App.js)
sendMessage: (message) => ipcRenderer.send('send-message', message),
onMessage: (callback) => ipcRenderer.on('receive-message', (event, ...args) => callback(...args)),
// NEW: Function to open a file dialog and read its content
openRecFile: async () => ipcRenderer.invoke('dialog:openRecFile'),
// NEW: Function to save content to a file using a save dialog
saveRecFile: async (fileContent, defaultFileName) => ipcRenderer.invoke('dialog:saveRecFile', fileContent, defaultFileName),
// NEW: Function to show an alert dialog (if you want to replace the custom React one with a native Electron one)
showAlert: async (message) => ipcRenderer.invoke('dialog:showAlert', message),
});