-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
84 lines (74 loc) · 2.25 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
76
77
78
79
80
81
82
83
84
// const electron = require('electron');
// const app = electron.app;
// const BrowserWindow = electron.BrowserWindow;
// //electron.crashReporter.start();
// var mainWindow = null;
// app.on('window-all-closed', function() {
// //if (process.platform != 'darwin') {
// app.quit();
// //}
// });
// app.on('ready', function() {
// // call python
// var subpy = require('child_process').spawn('python', ['./webserver/app.py']);
// var rq = require('request-promise');
// //var mainAddr = 'http://localhost:5000/music';
// var openWindow = function(){
// mainWindow = new BrowserWindow({width: 680, height: 450});
// mainWindow.setMenu(null);
// mainWindow.setResizable(false);
// // mainWindow.loadURL('file://' + __dirname + '/index.html');
// mainWindow.loadURL('http://localhost:5000/music');
// // mainWindow.webContents.openDevTools();
// mainWindow.on('closed', function() {
// mainWindow = null;
// subpy.kill('SIGINT');
// console.log('server stopped');
// });
// };
// var startUp = function(){
// rq(mainAddr)
// .then(function(htmlString){
// console.log('server started');
// openWindow();
// })
// .catch(function(err){
// console.log('waiting for the server start...');
// startUp();
// });
// };
// // fire!
// startUp();
// });
const electron = require('electron')
const {app, BrowserWindow} = require('electron')
const path = require('path')
const url = require('url')
app.on('window-all-closed', function() {
//if (process.platform != 'darwin') {
app.quit();
//}
});
function createWindow () {
var subpy = require('child_process').spawn('python', ['./webserver/app.py']);
// Create the browser window.
mainWindow = new BrowserWindow({
width: 680, height: 450,
resizable: false,
fullscreen: false
});
mainWindow.setMenu(null);
//mainWindow.setResizable(false);
// and load the index.html of the app.
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'public/index.html'),
protocol: 'file:',
slashes: true
}));
mainWindow.on('closed', function() {
mainWindow = null;
subpy.kill('SIGINT');
console.log('server stopped');
});
}
app.on('ready', createWindow);