-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
64 lines (50 loc) · 1.59 KB
/
Copy pathindex.js
File metadata and controls
64 lines (50 loc) · 1.59 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
const { app } = require('electron');
const ipcMain = require('./IpcMain/ipcMainEvents');
const { createWindow } = require('./defaultWindow');
const { createTray } = require('./Tray/tray');
const { autoUpdater, AppUpdater } = require('electron-updater');
let mainWin;
autoUpdater.autoDownload = false;
autoUpdater.autoInstallOnAppQuit = true;
const showMSGGUI = (chanel, ...msg) => {
mainWin.webContents.send(chanel, msg);
};
app.whenReady().then(() => {
setUpdaterListeners();
mainWin = createWindow({
loadFile: './client/Create.html',
positionX: 950,
positionY: 100,
});
mainWin.show();
mainWin.webContents.send('update', 'Checking for update');
mainWin.webContents.send('ver', app.getVersion());
autoUpdater.checkForUpdates();
createWindow({
loadFile: './client/Move.html',
positionX: 950,
positionY: 500,
}).show();
});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
const setUpdaterListeners = () => {
autoUpdater.on('update-available', (info) => {
showMSGGUI('update-color-signal', 'update-available', info);
autoUpdater.downloadUpdate();
});
autoUpdater.on('update-not-available', (info) => {
showMSGGUI('update-color-signal', 'It`s latest version');
});
autoUpdater.on('update-downloaded', (info) => {
const newVers = info.version;
showMSGGUI('update', 'update-downloaded', info);
setTimeout(() => { showMSGGUI('update', `Please restart app for updating to version ${newVers}`); }, 3000);
});
autoUpdater.on('error', (info) => {
showMSGGUI('update', 'error', info);
});
};