-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
49 lines (37 loc) · 1.31 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
const { app, ipcMain } = require('electron');
const Window = require('./src/js/Window');
const { PythonShell } = require("python-shell");
const Keep = require("./src/js/Keep");
let mainWindow = null;
let keep = new Keep();
function main () {
// Creates an object of a browser window class which shall
// be used throughout as the main interface to the window
mainWindow = new Window({file:'file://' + __dirname + '/src/index.html'});
// Loads the index.html page in the electron browser
mainWindow.on('closed', () => {
// Dereference the window object so as to delete it
mainWindow = null;
})
}
// Start point for the application for most use cases
app.on('ready', main);
ipcMain.on('openGoogleLogin', () => {
mainWindow.loadURL('file://' + __dirname + '/src/login.html');
});
ipcMain.on('loginSubmit', (event, username, password) => {
let pythonOptions = {
pythonPath: 'venv/bin/python',
pythonOptions: ['-u'], // get print results in real-time
args: [username, password]
};
PythonShell.run('src/external-python/login.py', pythonOptions, function (err, results) {
if (err) throw err;
console.log(results);
});
keep.getNotes(username);
mainWindow.loadURL('file://' + __dirname + '/src/index.html');
});
app.on('window-all-closed', () => {
app.quit();
});