forked from zadam/trilium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
electron.js
47 lines (35 loc) · 1.24 KB
/
electron.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
'use strict';
const {app, globalShortcut} = require('electron');
const sqlInit = require('./src/services/sql_init');
const appIconService = require('./src/services/app_icon');
const windowService = require('./src/services/window');
// Adds debug features like hotkeys for triggering dev tools and reload
require('electron-debug')();
appIconService.installLocalAppIcon();
require('electron-dl')({ saveAs: true });
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
else if (process.platform === 'win32') {
app.exit(0); // attempt to fix the issue when app.quite() won't terminate processes on windows
}
});
app.on('ready', async () => {
app.setAppUserModelId('com.github.zadam.trilium');
await sqlInit.dbConnection;
// if schema doesn't exist -> setup process
// if schema exists, then we need to wait until the migration process is finished
if (await sqlInit.schemaExists()) {
await sqlInit.dbReady;
await windowService.createMainWindow();
}
else {
await windowService.createSetupWindow();
}
await windowService.registerGlobalShortcuts();
});
app.on('will-quit', () => {
globalShortcut.unregisterAll();
});
require('./src/www');