-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.js
76 lines (58 loc) · 1.8 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
/*
Modules to control application and create browser windows
*/
const {app, BrowserWindow} = require('electron');
const path = require('path');
const StoreData = require('./user_data/store.js');
// const Store = require('./lib/user_management.js');
const birb = require('./user_data/birb.js');
const _nfd = require('./lib/nfd_operations.js');
const um = require('./lib/user_management');
let mainWindow;
const store = new StoreData({
configName: 'user-preferences',
defaults: {
// 800x600 is the default size of our window
windowBounds: { width: 800, height: 600 }
}
});
function createWindow () {
// Create the browser window.
let { width, height } = store.get('windowBounds');
mainWindow = new BrowserWindow({width, height});
mainWindow.loadFile('login.html');
mainWindow.on('closed', function () {
mainWindow = null
})
}
app.on('ready', function() {
let { width, height } = store.get('windowBounds');
mainWindow = new BrowserWindow({ width, height });
mainWindow.on('resize', () => {
let { width, height } = mainWindow.getBounds();
store.set('windowBounds', { width, height });
});
var flag = um.checkIfUserExist();
if (flag){
mainWindow.loadURL('file://' + path.join(__dirname, 'index.html'));
}
else {
mainWindow.loadURL('file://' + path.join(__dirname, 'login.html'));
}
});
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') {
app.quit()
}
});
app.on('activate', function () {
if (mainWindow === null) {
createWindow()
}
});
// Export the public available functions
module.exports = {
// getUsername,
// getAppDataPath
};
//All the main processes can go here, otherwise, it can go on some other file but needs require here