-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
59 lines (46 loc) · 1.32 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
const { app, BrowserWindow } = require('electron')
const {spawn} = require("child_process");
const path = require('path');
let win;
// TODO detach execution of app from Terminal when double click on .command
function createWindow () {
// Create the browser window.
win = new BrowserWindow({
width: 1200,
height: 800,
backgroundColor: '#ffffff',
icon: `file://${__dirname}/dist/assets/logo.png`
})
// Set the title of the application window
win.setTitle('Recipe Keeper');
win.loadURL(`file://${__dirname}/dist/Recipe-Keeper/index.html`)
// DevTools.
//win.webContents.openDevTools()
// Event when the window is closed.
win.on('closed', function () {
win = null
})
}
const iconPath = path.join(__dirname, '/dist/Recipe-Keeper/assets/logo.png');
app.dock.setIcon(iconPath);
app.on('ready', () => {
createWindow();
// Start Node.js server on port 3000
const serverProcess = spawn('node', ['server/server.js']);
serverProcess.stdout.on('data', (data) => {
console.log(`Server stdout: ${data}`);
});
serverProcess.stderr.on('data', (data) => {
console.error(`Server stderr: ${data}`);
});
});
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', function () {
if (win === null) {
createWindow();
}
});