-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
47 lines (38 loc) · 1.24 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
const { app, BrowserWindow } = require('electron')
const express = require('express')
const path = require('path')
// Create an instance of the Express app
const expressApp = express()
// Configure the Express app
expressApp.use(express.json())
expressApp.use(express.urlencoded({ extended: true }))
expressApp.use(express.static(path.join(__dirname, 'index.js')))
// Define your Express app routes here
// Create a new BrowserWindow when Electron has finished initializing
app.whenReady().then(() => {
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
},
})
// Load your Express app in the BrowserWindow
mainWindow.loadURL('http://localhost:5000')
// Open DevTools
mainWindow.webContents.openDevTools()
})
// Quit the app when all windows are closed, except on macOS where it is common
// for applications and their menu bar to stay active until the user quits
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
// Re-create the BrowserWindow when the app is activated but no windows are open
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})