-
Notifications
You must be signed in to change notification settings - Fork 0
/
preload.js
30 lines (26 loc) · 833 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
25
26
27
28
29
30
window.addEventListener('DOMContentLoaded', () => {
const replaceText = (selector, text) => {
const element = document.getElementById(selector)
if (element) element.innerText = text
}
for (const dependency of ['chrome', 'node', 'electron']) {
replaceText(`${dependency}-version`, process.versions[dependency])
}
})
const {contextBridge, ipcRenderer} = require('electron');
contextBridge.exposeInMainWorld(
"electron",
{
send: ipcRenderer.send,
on: (channel, callback) => {
ipcRenderer.on(channel, (event, ...args) => callback(...args));
}
}
);
window.addEventListener('resize', () => {
const dimensions = {
width: window.innerWidth,
height: window.innerHeight
};
ipcRenderer.send('window-resize', dimensions);
});