forked from sauber92/GraduationProject-TA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
69 lines (54 loc) · 1.38 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
const electron = require('electron');
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;
const path = require('path');
var mainWindow,
loadingScreen,
windowParams = {
width: 900,
height: 630,
show: false,
icon: path.join(__dirname, 'public/img/icons/Icon.png')
};
function onClosed() {
mainWindow = null;
}
function createLoadingScreen() {
loadingScreen = new BrowserWindow(Object.assign(windowParams, {parent: mainWindow}));
loadingScreen.loadURL(`file://${__dirname}/loading.html`);
loadingScreen.on('closed', () => loadingScreen = null);
loadingScreen.webContents.on('did-finish-load', () => {
loadingScreen.show();
});
}
function createWindow() {
mainWindow = new BrowserWindow(windowParams);
mainWindow.loadURL(`file://${__dirname}/index.html`);
mainWindow.webContents.on('did-finish-load', () => {
mainWindow.show();
if (loadingScreen) {
var loadingScreenBounds = loadingScreen.getBounds();
mainWindow.setBounds(loadingScreenBounds);
loadingScreen.close();
}
});
mainWindow.on('closed', function() {
mainWindow = null;
});
}
app.on('ready', () => {
createLoadingScreen();
setTimeout(function(){
createWindow();
}, 2000);
});
app.on('activate', () => {
if(!mainWindow) {
createWindow();
}
});
app.on('window-all-closed', () => {
if(process.platform != 'darwin') {
app.quit();
}
});