-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreload.js
More file actions
32 lines (28 loc) · 875 Bytes
/
preload.js
File metadata and controls
32 lines (28 loc) · 875 Bytes
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
// All of the Node.js APIs are available in the preload process.
// It has the same sandbox as a Chrome extension.
const {
contextBridge,
ipcRenderer
} = require('electron');
// window.addEventListener('DOMContentLoaded', () => {
// const replaceText = (selector, text) => {
// const element = document.getElementById(selector);
// if (element) {
// element.innerText = text;
// }
// };
// for (const type of ['chrome', 'node', 'electron']) {
// replaceText(`${type}-version`, process.versions[type]);
// }
// });
// Expose protected methods that allow the renderer process to use
// the ipcRenderer without exposing the entire object
contextBridge.exposeInMainWorld(
'electron',
{
'platform': process.platform,
'quitApp': () => ipcRenderer.send('quitApp'),
'lock': () => ipcRenderer.send('lock'),
'sleep': () => ipcRenderer.send('sleep')
}
);