-
Notifications
You must be signed in to change notification settings - Fork 0
/
promagen.js
96 lines (76 loc) · 2.73 KB
/
promagen.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
85
86
87
88
89
90
91
92
93
94
95
// Modules to control application life and create native browser window
const electron = require('electron');
const app = electron.app; // Module to control application life.
const BrowserWindow = electron.BrowserWindow; // Module to create native browser window.
const path = require('path');
const web = require('./src/web'); // Start Express web app based on Express
// CONFIG
const PublicConfig = require('./config/projects');
var localConfig = new PublicConfig();
// Name of the product, used in some app labels
const productName = require('./package.json').productName;
// var webServer;
var shuttingDown;
function startExpress() {
// require('../src/web')(); // Start Express web app based on Express
return new web();
}
function createWindow() {
var icon_file = path.join(__dirname, "/public/images/promagen32.png");
console.log('icon_file:', icon_file);
// Create the browser window.
const mainWindow = new BrowserWindow({
autoHideMenuBar: true,
width: 1280,
height: 720,
// backgroundcolor: '#2e2c29',
// autoHideMenuBar: true,
// useContentSize: true,
title: productName,
// webPreferences: {
// nodeIntegration: true
// preload: path.join(__dirname, 'public/electron/preload.js')
// }
icon: icon_file
});
// var localurl = 'http://localhost:' + localConfig.port + '/';
// console.log(localurl);
// mainWindow.loadURL(localurl);
var localfile = './public/electron/index.html';
console.log(localfile);
mainWindow.loadFile(localfile);
// mainWindow.webContents.openDevTools();
}
// Some APIs can only be used after this event occurs.
app.on('ready', function () {
shuttingDown = false;
startExpress();
// require('../src/web')(); // Start Express web app based on Express
createWindow(); // Open the Window
});
// Called before quitting...gives us an opportunity to shutdown the child process
app.on('before-quit', function () {
// Need this to make sure we don't kick things off again in the child process
shuttingDown = true;
// Kill the web process
// webServer.kill();
});
// Quit when all windows are closed.
app.on('window-all-closed', function () {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit()
}
});
process.on("SIGINT", function () {
//graceful shutdown
process.exit();
});
app.on('activate', function () {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createWindow()
}
});