-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
30 lines (25 loc) · 954 Bytes
/
main.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
const { app, BrowserWindow, Menu, ipcMain } = require('electron')
const { enable } = require('@electron/remote/main')
const { MenuItem } = require('electron/main')
let template = [{role: 'toggleDevTools'}, {role: 'reload' }, {role: 'undo'}, {role: 'zoomIn'}, {role: 'zoomOut'}]
let contextMenu=Menu.buildFromTemplate(template)
function createWindow () {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
enableRemoteModule: true // to enable use of remote module in renderer process
}
})
// Enable remote module for the window
enable(win.webContents)
win.loadFile('index.html')
let noteItem = new MenuItem({label: 'create Note', click: ()=>{win.webContents.send('create-new-note')}})
contextMenu.append(noteItem);
win.webContents.on('context-menu', ()=> {
contextMenu.popup();
})
}
app.whenReady().then(createWindow)