Files
markdownblog/electron/main.js
2025-07-27 17:13:21 +02:00

45 lines
973 B
JavaScript

const { app, BrowserWindow } = require('electron');
const path = require('path');
const isDev = process.env.NODE_ENV === 'development';
/*
This will be discontinued in a bit.
Either move to Docker or get fucked.
*/
function createWindow() {
const mainWindow = new BrowserWindow({
width: 1200,
height: 800,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
},
});
// Load the Next.js app
if (isDev) {
const baseUrl = process.env.BASE_URL || '';
const url = `http://localhost:3000${baseUrl}`;
mainWindow.loadURL(url);
mainWindow.webContents.openDevTools();
} else {
mainWindow.loadFile(path.join(__dirname, '../.next/server/pages/index.html'));
}
}
app.whenReady().then(createWindow);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});