You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.2 KiB
51 lines
1.2 KiB
'use strict' |
|
|
|
const { app, BrowserWindow, shell } = require('electron') |
|
const path = require('path') |
|
|
|
/** True when running from source (`electron .`); false when packaged. */ |
|
const isDev = !app.isPackaged |
|
|
|
function createWindow() { |
|
const win = new BrowserWindow({ |
|
width: 1280, |
|
height: 840, |
|
minWidth: 400, |
|
minHeight: 500, |
|
show: false, |
|
webPreferences: { |
|
preload: path.join(__dirname, 'preload.cjs'), |
|
contextIsolation: true, |
|
nodeIntegration: false, |
|
sandbox: true |
|
} |
|
}) |
|
|
|
win.once('ready-to-show', () => win.show()) |
|
|
|
if (isDev) { |
|
const devUrl = process.env.VITE_DEV_SERVER_URL || 'http://127.0.0.1:5173' |
|
win.loadURL(devUrl) |
|
win.webContents.openDevTools({ mode: 'detach' }) |
|
} else { |
|
win.loadFile(path.join(__dirname, '..', 'dist', 'index.html')) |
|
} |
|
|
|
win.webContents.setWindowOpenHandler(({ url }) => { |
|
if (url.startsWith('http:') || url.startsWith('https:')) { |
|
void shell.openExternal(url) |
|
} |
|
return { action: 'deny' } |
|
}) |
|
} |
|
|
|
app.whenReady().then(() => { |
|
createWindow() |
|
app.on('activate', () => { |
|
if (BrowserWindow.getAllWindows().length === 0) createWindow() |
|
}) |
|
}) |
|
|
|
app.on('window-all-closed', () => { |
|
if (process.platform !== 'darwin') app.quit() |
|
})
|
|
|