Files
ep-mail-client/desktop/main.cjs
T

40 lines
1.1 KiB
JavaScript

const { app, BrowserWindow, shell } = require('electron');
const path = require('node:path');
function createWindow() {
const window = new BrowserWindow({
width: 1440,
height: 920,
minWidth: 920,
minHeight: 680,
title: 'Daybreak Mail',
backgroundColor: '#f4f5f1',
autoHideMenuBar: true,
icon: path.join(__dirname, '..', 'icon.svg'),
webPreferences: {
contextIsolation: true,
nodeIntegration: false,
sandbox: true
}
});
window.loadFile(path.join(__dirname, '..', 'index.html'));
window.webContents.setWindowOpenHandler(({ url }) => {
if (url.startsWith('https://') || url.startsWith('mailto:')) shell.openExternal(url);
return { action: 'deny' };
});
window.webContents.on('will-navigate', event => event.preventDefault());
}
app.whenReady().then(() => {
app.setAppUserModelId('studio.daybreak.mail');
createWindow();
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit();
});