Files
ChatOA/client/electron/main.cjs
T

39 lines
931 B
JavaScript

const { app, BrowserWindow } = require('electron');
const path = require('path');
const DEV_SERVER_URL = process.env.VITE_DEV_SERVER_URL;
function createWindow() {
const win = new BrowserWindow({
width: 1200,
height: 800,
minWidth: 980,
minHeight: 640,
title: `ChatOA v${app.getVersion()}`,
autoHideMenuBar: true,
webPreferences: {
preload: path.join(__dirname, 'preload.cjs'),
contextIsolation: true,
nodeIntegration: false,
},
});
if (DEV_SERVER_URL) {
win.loadURL(DEV_SERVER_URL);
win.webContents.openDevTools({ mode: 'detach' });
} else {
win.loadFile(path.join(__dirname, '..', 'dist', 'index.html'));
}
}
app.whenReady().then(() => {
createWindow();
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit();
});