mirror of
https://gitlab.com/RemixDev/deemix-gui.git
synced 2024-12-28 02:26:13 +00:00
26 lines
865 B
JavaScript
26 lines
865 B
JavaScript
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 = ["openDownloadsFolder", "applogin", "selectDownloadFolder"];
|
|
if (validChannels.includes(channel)) {
|
|
ipcRenderer.send(channel, data);
|
|
}
|
|
},
|
|
receive: (channel, func) => {
|
|
let validChannels = ["downloadFolderSelected", "applogin_arl"];
|
|
if (validChannels.includes(channel)) {
|
|
// Deliberately strip event as it includes `sender`
|
|
ipcRenderer.on(channel, (event, ...args) => func(...args));
|
|
}
|
|
}
|
|
}
|
|
);
|