-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.js
More file actions
53 lines (46 loc) · 1.02 KB
/
main.js
File metadata and controls
53 lines (46 loc) · 1.02 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
47
48
49
50
51
52
53
'use strict';
const { app, BrowserWindow, Menu } = require('electron');
let win;
function createWindow() {
win = new BrowserWindow({ width: 1440, height: 900 });
win.loadFile('index.html');
// win.webContents.openDevTools()
win.on('closed', () => {
win = null;
});
}
function createMenu() {
var menu = Menu.buildFromTemplate([
{
label: 'Paper',
submenu: [
{ role: 'quit' },
],
},
{ role: 'editMenu' },
{ role: 'windowMenu' },
]);
Menu.setApplicationMenu(menu);
};
app.on('ready', function () {
createWindow();
createMenu();
});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('web-contents-created', function (webContentsCreatedEvent, contents) {
if (contents.getType() === 'webview') {
contents.on('new-window', function (newWindowEvent, url) {
// console.log('block');
newWindowEvent.preventDefault();
});
}
});
app.on('activate', () => {
if (win === null) {
createWindow()
}
});