-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
356a5bb
commit c755449
Showing
3 changed files
with
38 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
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 = ["toMain"]; | ||
if (validChannels.includes(channel)) { | ||
ipcRenderer.send(channel, data); | ||
} | ||
}, | ||
receive: (channel, func) => { | ||
let validChannels = ["fromMain"]; | ||
if (validChannels.includes(channel)) { | ||
// Deliberately strip event as it includes `sender` | ||
ipcRenderer.on(channel, (event, ...args) => func(...args)); | ||
} | ||
} | ||
} | ||
); |
c755449
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where are you actually using preload.js? ui.html still has a require('electron') that completely stops this app from working due to this update.