26 lines
808 B
TypeScript
26 lines
808 B
TypeScript
import { BrowserWindow } from 'electron';
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
process.env.APP_ROOT = path.join(__dirname, '..');
|
|
|
|
export function createMailWindow({ RENDERER_DIST }: { RENDERER_DIST: string }) {
|
|
let newWin: BrowserWindow | null = new BrowserWindow({
|
|
width: 600,
|
|
height: 400,
|
|
webPreferences: {
|
|
preload: path.join(__dirname, 'preload.mjs'),
|
|
},
|
|
});
|
|
|
|
const url = process.env.VITE_DEV_SERVER_URL ? `${process.env.VITE_DEV_SERVER_URL}/#/mails` : `file://${path.join(RENDERER_DIST, 'index.html')}#/mails`;
|
|
|
|
newWin.loadURL(url);
|
|
|
|
newWin.on('closed', () => {
|
|
newWin = null;
|
|
});
|
|
|
|
return newWin;
|
|
}
|