-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
59 lines (47 loc) · 1.36 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
// eslint-disable-next-line no-unused-vars
const { AppVersion } = require("./main/AppVersion.js");
const { app, nativeTheme } = require('electron');
const { autoUpdater } = require("electron-updater");
const { enforceSingleInstance } = require("./main/Utils.js");
const { WindowManager } = require("./main/WindowManager.js");
const fs = require("fs");
const path = require("path");
function init () {
autoUpdater.checkForUpdatesAndNotify();
if (enforceSingleInstance()) {
return;
}
const aUserDataFolder = [
"traineddata"
];
createUserDataFolder(aUserDataFolder);
WindowManager.addMain('index.html');
WindowManager.addWorker('./worker/database.html');
}
function createUserDataFolder (aFolder) {
const sUserData = app.getPath("userData");
aFolder.forEach(sFolder => {
sFolder = path.join(sUserData, sFolder);
if (!fs.existsSync(sFolder)) {
fs.mkdirSync(sFolder);
}
});
}
app.on('ready', init.bind(this));
app.on('second-instance', () => {
WindowManager.focusMain();
});
app.on('activate', () => {
if (WindowManager.mainLoaded()) {
init();
}
});
app.on('before-quit', (oEvent) => {
WindowManager.close(oEvent);
});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
};
});
nativeTheme.themeSource = 'light';