mirror of
https://github.com/sern-handler/gui
synced 2026-06-06 01:16:54 +00:00
45 lines
889 B
JavaScript
45 lines
889 B
JavaScript
const path = require('path');
|
|
const { app, BrowserWindow } = require('electron');
|
|
const isDev = require('electron-is-dev');
|
|
|
|
function createWindow() {
|
|
const mainWindow = new BrowserWindow({
|
|
width: 800,
|
|
height: 600,
|
|
webPreferences: {
|
|
nodeIntegration: true,
|
|
},
|
|
icon: './icons/icon.png',
|
|
show: false,
|
|
autoHideMenuBar: true,
|
|
title: 'sern',
|
|
});
|
|
if (isDev) {
|
|
mainWindow.loadURL('http://localhost:3000');
|
|
} else {
|
|
mainWindow.loadFile(path.join(__dirname, '../build/index.html'));
|
|
}
|
|
|
|
mainWindow.on('ready-to-show', () => {
|
|
mainWindow.show();
|
|
});
|
|
|
|
mainWindow.on('page-title-updated', function (e) {
|
|
e.preventDefault();
|
|
});
|
|
}
|
|
|
|
app.whenReady().then(createWindow);
|
|
|
|
app.on('window-all-closed', () => {
|
|
if (process.platform !== 'darwin') {
|
|
app.quit();
|
|
}
|
|
});
|
|
|
|
app.on('activate', () => {
|
|
if (BrowserWindow.getAllWindows().length === 0) {
|
|
createWindow();
|
|
}
|
|
});
|