-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
96 lines (81 loc) · 1.84 KB
/
main.js
File metadata and controls
96 lines (81 loc) · 1.84 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
const { app, BrowserWindow, dialog } = require('electron');
const { autoUpdater } = require('electron-updater');
autoUpdater.autoDownload = false;
let template = [];
if (process.platform === 'darwin') {
// OS X
const name = app.getName();
template.unshift({
label: name,
submenu: [
{
label: 'About ' + name,
role: 'about',
},
{
label: 'Quit',
accelerator: 'Command+Q',
click() {
app.quit();
},
},
],
});
}
let win;
function sendStatusToWindow(text) {
win.webContents.send('message', text);
}
function createDefaultWindow() {
win = new BrowserWindow();
win.on('closed', () => {
win = null;
});
win.maximize();
win.show();
win.loadURL('http://www.wmsgosoftware.com');
return win;
}
autoUpdater.on('checking-for-update', () => {
sendStatusToWindow('Checking for update...');
});
autoUpdater.on('error', (err) => {
sendStatusToWindow('Error in auto-updater. ' + err);
});
autoUpdater.on('update-available', () => {
dialog.showMessageBox(
{
type: 'info',
title: 'Found Updates',
message: 'Found updates, do you want update now?',
buttons: ['Sure', 'No'],
},
(buttonIndex) => {
if (buttonIndex === 0) {
autoUpdater.downloadUpdate();
} else {
}
}
);
});
autoUpdater.on('download-progress', (progressObj) => {
sendStatusToWindow(progressObj.percent);
});
autoUpdater.on('update-downloaded', () => {
dialog.showMessageBox(
{
title: 'Install Updates',
message: 'Updates downloaded, application will be quit for update...',
},
() => {
setImmediate(() => autoUpdater.quitAndInstall());
}
);
});
app.on('ready', function () {
createDefaultWindow();
autoUpdater.checkForUpdatesAndNotify();
});
app.on('window-all-closed', () => {
app.quit();
});