-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
executable file
·46 lines (40 loc) · 1.05 KB
/
main.js
File metadata and controls
executable file
·46 lines (40 loc) · 1.05 KB
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
45
46
const { app, BrowserWindow, Menu } = require('electron');
require('@electron/remote/main').initialize();
let win;
function createWindow() {
win = new BrowserWindow({
width: 400,
height: 900,
minWidth: 300,
minHeight: 400,
frame: false,
transparent: true,
alwaysOnTop: true,
resizable: true,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
}
});
require('@electron/remote/main').enable(win.webContents);
win.loadFile('index.html');
// Context menu
win.webContents.on('context-menu', (e, params) => {
const isOnTop = win.isAlwaysOnTop();
const menu = Menu.buildFromTemplate([
{
label: isOnTop ? '✓ Stay on Top' : 'Stay on Top',
type: 'checkbox',
checked: isOnTop,
click: () => {
win.setAlwaysOnTop(!isOnTop);
}
}
]);
menu.popup();
});
}
app.whenReady().then(createWindow);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit();
});