-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
47 lines (38 loc) · 949 Bytes
/
main.js
File metadata and controls
47 lines (38 loc) · 949 Bytes
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, shell, BrowserWindow } = require('electron')
if (process.env.ELECTRON_NODE_ENV === 'development') {
try {
require('electron-reloader')(module)
} catch (_) {}
}
function createWindow () {
const win = new BrowserWindow({
width: 320,
height: 450,
resizable: false,
webPreferences: {
nodeIntegration: true
}
})
win.loadFile('views/popup.html')
// Open the DevTools.
if (process.env.ELECTRON_NODE_ENV === 'development') {
win.webContents.openDevTools({ mode: 'detach'})
}
win.webContents.on('new-window', function(event, url) {
if (url || url.includes('http')) {
event.preventDefault()
shell.openExternal(url)
}
})
}
app.whenReady().then(createWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})