IYUUPlus-Windows/main.js

31 lines
715 B
JavaScript
Raw Normal View History

2024-06-27 18:27:45 +08:00
const { app, BrowserWindow, Menu } = require('electron')
2024-06-27 17:29:25 +08:00
const path = require('node:path')
const server = require('./server/server');
const createWindow = () => {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
preload: path.join(__dirname, 'preload.js')
}
})
2024-06-27 18:27:45 +08:00
require("./menu/menu.js")
2024-06-27 17:29:25 +08:00
win.loadURL('http://127.0.0.1:8787')
}
app.whenReady().then(() => {
server.startServer()
createWindow()
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
})
app.on('window-all-closed', () => {
server.stopServer()
if (process.platform !== 'darwin') app.quit()
})