-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreload.js
24 lines (23 loc) · 843 Bytes
/
preload.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const {
contextBridge,
ipcRenderer
} = require("electron");
// Expose protected methods that allow the renderer process to use
// the ipcRenderer without exposing the entire object
contextBridge.exposeInMainWorld(
"api", {
send: (channel, data) => {
// whitelist channels
let validChannels = ["save-note", 'show-form', 'notes-data', 'send-path-to-notes'];
if (validChannels.includes(channel)) {
ipcRenderer.send(channel, data);
}
},
receive: (channel, data) => {
let validChannels = ["save-note-reply", 'form-show-request', 'notes-data-reply', 'save-note-request', 'get-path-to-notes', 'load-file'];
if (validChannels.includes(channel)) {
ipcRenderer.on(channel, data);
}
}
}
);