-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
92 lines (81 loc) · 3.16 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
87
88
89
90
91
92
/*-----------------------------------------------------------------------------------------------------------\
| _____ _ _____ _ _ _ _____ _____ _____ __ _______ _____ _____ _____ |
| |_ _| (_) / ___| | | (_) / __ \| _ |/ __ \/ | / / __ \| _ |/ __ \|____ | |
| | | __ _ _ \ `--.| |_ _ _ __| |_ ___ `' / /'| |/' |`' / /'`| | / /`' / /'| |/' |`' / /' / / |
| | |/ _` | | `--. \ __| | | |/ _` | |/ _ \ / / | /| | / / | | / / / / | /| | / / \ \ |
| | | (_| | | /\__/ / |_| |_| | (_| | | (_) | ./ /___\ |_/ /./ /____| |_/ / ./ /___\ |_/ /./ /___.___/ / |
| \_/\__,_|_| \____/ \__|\__,_|\__,_|_|\___/ \_____/ \___/ \_____/\___/_/ \_____/ \___/ \_____/\____/ |
\-----------------------------------------------------------------------------------------------------------*/
const { app, BrowserWindow, ipcMain } = require('electron');
const log = require('electron-log');
const { autoUpdater } = require('electron-updater');
//AUTO UPDATE
autoUpdater.logger = log;
autoUpdater.logger.transports.file.level = 'info';
autoUpdater.autoDownload = true;
var control = null,
prompteur = null;
app.whenReady().then(() => {
autoUpdater.checkForUpdates();
control = createWindow('app/index.html', 800, 600, true);
prompteur = createWindow('app/prompteur.html', 800, 600, true);
ipcMain.on('always', (event, arg) => {
prompteur.setAlwaysOnTop(arg);
});
ipcMain.on('start', (event, arg, arg1) => {
prompteur.webContents.executeJavaScript(`starting('${arg}', '${arg1}')`);
});
ipcMain.on('script', (event, arg) => {
prompteur.webContents.executeJavaScript(`script('${replaceALL(arg, '\n', '<br />')}')`);
});
//AUTO UPDATE
autoUpdater.on('checking-for-update', () => {
});
autoUpdater.on('update-available', (ev, info) => {
});
autoUpdater.on('update-not-available', (ev, info) => {
});
autoUpdater.on('error', (ev, err) => {
});
autoUpdater.on('download-progress', (ev, progressObj) => {
});
autoUpdater.on('update-downloaded', (ev, info) => {
setTimeout(function() {
quit(false, true);
}, 5000)
});
});
//QUIT OR RELAUNCH
function quit(arg, arg1){
for(i=0;i<allTimers.length;i++){
clearInterval(allTimers[i]);
if(i == allTimers.length -1){
if(arg){
app.relaunch();
}
if(arg1){
autoUpdater.quitAndInstall();
}
app.quit();
}
}
}
function createWindow(file, w, h, resize) {
var win = new BrowserWindow({
width: w,
height: h,
resizable: resize,
autoHideMenuBar: true,
webPreferences: {
contextIsolation: false,
nodeIntegration: true
}
});
win.loadFile(file);
return win;
}
function replaceALL(str,replaceWhat,replaceTo){
replaceWhat = replaceWhat.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
var re = new RegExp(replaceWhat, 'g');
return str.replace(re,replaceTo);
}