41 lines
911 B
JavaScript
41 lines
911 B
JavaScript
const { app, BrowserWindow } = require('electron')
|
|
const path = require('path')
|
|
|
|
const isDev = !app.isPackaged
|
|
|
|
function createWindow() {
|
|
const win = new BrowserWindow({
|
|
width: 1280,
|
|
height: 900,
|
|
minWidth: 900,
|
|
minHeight: 600,
|
|
title: 'WhatTheFlat',
|
|
webPreferences: {
|
|
preload: path.join(__dirname, 'preload.cjs'),
|
|
contextIsolation: true,
|
|
nodeIntegration: false,
|
|
},
|
|
})
|
|
|
|
if (isDev) {
|
|
// Dev: load from Vite dev server
|
|
win.loadURL('http://localhost:5173')
|
|
win.webContents.openDevTools()
|
|
} else {
|
|
// Production: load built files from disk
|
|
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()
|
|
})
|