34 lines
833 B
JavaScript
34 lines
833 B
JavaScript
// electron-main.js
|
|
const { app, BrowserWindow } = require('electron');
|
|
const path = require('path');
|
|
|
|
function createWindow() {
|
|
const win = new BrowserWindow({
|
|
width: 1200,
|
|
height: 800,
|
|
webPreferences: {
|
|
preload: path.join(__dirname, 'preload.js'),
|
|
contextIsolation: true,
|
|
sandbox: false
|
|
}
|
|
});
|
|
// win.webContents.openDevTools();
|
|
|
|
if (app.isPackaged) {
|
|
win.loadFile(path.join(__dirname, 'frontend/dist/index.html'));
|
|
} else {
|
|
win.loadURL('http://localhost:5173');
|
|
}
|
|
}
|
|
|
|
app.whenReady().then(() => {
|
|
createWindow();
|
|
|
|
app.on('activate', () => {
|
|
if (BrowserWindow.getAllWindows().length === 0) createWindow();
|
|
});
|
|
});
|
|
|
|
app.on('window-all-closed', () => {
|
|
if (process.platform !== 'darwin') app.quit();
|
|
}); |