-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathpreload.js
39 lines (38 loc) · 1.18 KB
/
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('api', {
send: (channel, data) => {
const validSendChannels = [
'app_version',
'minimize-window',
'maximize-window',
'unmaximize-window',
'close-window',
'run-ffmpeg-command',
'get-audio-metadata',
'open-file-dialog',
'open-folder-dialog',
'get-path-separator'
];
if (validSendChannels.includes(channel)) {
ipcRenderer.send(channel, data);
}
},
receive: (channel, func) => {
const validReceiveChannels = [
'app_version',
'ffmpeg-output',
'ffmpeg-error',
'audio-metadata-response',
'selected-file-paths',
'selected-folder',
'path-separator-response',
'ffmpeg-progress'
];
if (validReceiveChannels.includes(channel)) {
ipcRenderer.on(channel, (event, ...args) => func(...args));
}
},
removeAllListeners: (channel) => {
ipcRenderer.removeAllListeners(channel);
}
});