-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
67 lines (55 loc) · 1.55 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// require dependencies
const electron = require('electron')
const fs = require('fs')
const app = electron.app
const BrowserWindow = electron.BrowserWindow
// setup window objects
let mainWindow
let win
// create window handler
function createWindow() {
// Create the browser window.
mainWindow = new BrowserWindow({
width: 1000,
height: 700,
frame: false,
icon: __dirname + '/images/icon.png',
})
// Remove menu
mainWindow.setMenu(null);
// and load the index.html of the app.
mainWindow.loadURL(`file://${__dirname}/index.html`)
// Open the DevTools.
mainWindow.webContents.openDevTools()
// Emitted when the window is closed.
mainWindow.on('closed', function() {
mainWindow = null
if (win != null) { // if there is a secondary window, close it
win = null
}
})
mainWindow.webContents.on('new-window', (event, url) => { // if a new window is made, initialize it with different settings
event.preventDefault()
win = new BrowserWindow({
frame: true,
width: 1300,
height: 700
})
win.setMenu(null)
win.once('ready-to-show', () => win.show())
win.loadURL(url)
event.newGuest = win
})
}
app.on('ready', createWindow)
app.on('window-all-closed', function() {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', function() {
if (mainWindow === null) {
createWindow()
}
})
// if a settings file does not exist, create it