-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
86 lines (68 loc) · 1.93 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
75
76
77
78
79
80
81
82
83
84
85
86
const { app, BrowserWindow, ipcMain } = require('electron')
const { autoUpdater } = require('electron-updater');
const path = require('path')
let win;
const iconPath = process.platform !== 'darwin'
? 'src/assets/icons/icon.ico'
: 'src/assets/icons/icon.icns';
function createWindow() {
win = new BrowserWindow({
width: 1150,
height: 800,
resizable: false,
icon: path.join(iconPath),
frame: false,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
enableRemoteModule: true
}
})
//win.webContents.openDevTools();
win.setMenuBarVisibility(false);
win.once('ready-to-show', () => {
autoUpdater.autoDownload = false;
autoUpdater.checkForUpdates();
});
}
app.on('ready', () => {
createWindow();
win.loadFile('src/loading.html');
setTimeout(function() {
win.loadFile('src/index.html');
}, 2000);
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
})
ipcMain.on('app_version', (event) => {
event.sender.send('app_version', { version: app.getVersion() });
});
ipcMain.on('close_app', () => {
app.quit();
});
ipcMain.on('minimize_app', () => {
win.minimize();
});
autoUpdater.on('checking-for-update', () => {
sendStatusToWindow('Checking for updates...');
})
autoUpdater.on('update-available', (info) => {
sendStatusToWindow('An update is available! Downloading..');
autoUpdater.downloadUpdate();
})
autoUpdater.on('update-not-available', (info) => {
sendStatusToWindow('RLTrader is up to date.');
})
autoUpdater.on('error', (err) => {
sendStatusToWindow('Error in auto-updater. ' + err);
})
autoUpdater.on('update-downloaded', () => {
sendStatusToWindow('Update downloaded, restarting..');
autoUpdater.quitAndInstall();
});
function sendStatusToWindow(text) {
win.webContents.send('message', text);
}