-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.js
86 lines (73 loc) · 2 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
85
86
require = require("esm")(module/*, options*/)
module.exports = require("./main.js")
const { app, BrowserWindow, ipcMain } = require('electron')
const express = require('express')
const PerspectivismCore = require('./src/core/PerspectivismCore')
const core = PerspectivismCore.create()
app.whenReady().then(() => {
core.initServices()
core.startGraphQLServer()
const splash = createSplash()
core.waitForAgent().then(() => {
core.initControllers()
createWindow()
splash.close()
})
})
function createSplash () {
// Create the browser window.
const win = new BrowserWindow({
width: 1000,
height: 600,
webPreferences: {
nodeIntegration: true,
enableRemoteModule: true,
},
minimizable: false,
alwaysOnTop: true,
frame: false,
transparent: true,
})
// and load the index.html of the app.
win.loadURL(`file://${__dirname}/public/splash.html`)
// Open the DevTools.
//win.webContents.openDevTools()
return win
}
function createWindow () {
// Create the browser window.
const win = new BrowserWindow({
width: 1600,
height: 1000,
webPreferences: {
nodeIntegration: true,
enableRemoteModule: true,
}
})
// and load the index.html of the app.
win.loadURL(`file://${__dirname}/public/index.html`)
// Open the DevTools.
win.webContents.openDevTools()
return win
}
function serveUI() {
const expressApp = express()
expressApp.use(express.static(`${__dirname}/public`))
expressApp.listen(9090)
}
// Quit when all windows are closed, except on macOS. There, it's common
// for applications and their menu bar to stay active until the user quits
// explicitly with Cmd + Q.
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
// On macOS 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 (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})
serveUI()