-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreload.js
44 lines (40 loc) · 1.36 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
40
41
42
43
44
const { contextBridge, ipcRenderer } = require("electron");
const path = require("path");
const { Titlebar, TitlebarColor } = require("custom-electron-titlebar");
window.addEventListener("DOMContentLoaded", () => {
new Titlebar({
backgroundColor: TitlebarColor.fromHex("#000"),
overflow: "auto",
icon: path.join(__dirname, 'icon.png'),
iconSize: 20,
titleHorizontalAlignment: "left",
minimizable: true,
maximizable: true,
closeable: true,
tooltips: {
minimize: "Minimize",
maximize: "Maximize",
restoreDown: "Restore",
close: "Close"
},
enableMnemonics: true,
menuPosition: "left",
transparent: 0.5
});
});
contextBridge.exposeInMainWorld("electron", {
ipcRenderer: {
send: (channel, data) => ipcRenderer.send(channel, data),
receive: (channel, func) => ipcRenderer.on(channel, (event, ...args) => func(...args)),
invoke: (channel, data) => ipcRenderer.invoke(channel, data)
}
});
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])
}
});