-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathpreload.js
39 lines (29 loc) · 867 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
31
32
33
34
35
36
37
38
39
// All of the Node.js APIs are available in the preload process.
// It has the same sandbox as a Chrome extension.
const { remote, ipcRenderer } = require('electron');
const allowedUrls = ['https://akashrajpurohit.com'];
const isValidUrl = url => allowedUrls.includes(url);
const init = () => {
window.checkClipboard = () => {
return remote.clipboard.readText();
};
window.copyToClipboard = (text) => {
remote.clipboard.writeText(text);
};
window.openExternalUrl = (url) => {
if (isValidUrl(url)) remote.shell.openExternal(url);
};
window.clearClipboard = () => {
remote.clipboard.clear();
};
window.openMainWindow = () => {
ipcRenderer.send('open-main-window');
};
window.minimizeApp = () => {
ipcRenderer.send('minimize-app');
};
window.quitApp = () => {
ipcRenderer.send('quit-app');
};
};
init();