-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
74 lines (60 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
68
69
70
71
72
73
74
const { app, BrowserWindow, ipcMain } = require('electron')
const log = require('electron-log')
const { autoUpdater } = require('electron-updater')
let win
function createWindow() {
win = new BrowserWindow({
title: 'Spectrum Editor',
icon: `${__dirname}/resources/icon.png`,
frame: false,
width: 640,
height: 480,
minWidth: 400,
minHeight: 200
})
win.loadURL(`file://${__dirname}/index.html`)
win.on('closed', () => {
win = null
})
win.webContents.on('will-navigate', (e, url) => {
e.preventDefault()
win.webContents.send('open-file', url.slice(7))
})
win.on('restore', () => {
win.webContents.send('restore')
})
}
log.info("App starting...")
autoUpdater.logger = log
autoUpdater.logger.transports.file.level = 'info'
autoUpdater.on('update-downloaded', (info) => {
autoUpdater.quitAndInstall()
})
app.on('ready', () => {
createWindow()
autoUpdater.checkForUpdates()
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (win === null) {
createWindow()
}
})
ipcMain.on('open-settings', () => {
new BrowserWindow({
title: win.getTitle() + " Settings",
parent: win,
modal: true,
frame: false,
width: 400,
height: 500,
resizable: false
}).loadURL(`file://${__dirname}/settings.html`)
})
ipcMain.on('settings-changed', () => {
win.webContents.send('settings-changed')
})