mirror of
https://github.com/Anil-matcha/Open-Generative-AI.git
synced 2026-05-07 01:17:18 +00:00
- Add electron/main.js as the Electron main process - Configure electron-builder for macOS (x64 + arm64 DMG) and Windows (x64 + arm64 NSIS installer) - Add build scripts: electron:build (mac), electron:build:win (windows) - Set vite base to './' for file:// protocol compatibility in Electron
59 lines
1.4 KiB
JavaScript
59 lines
1.4 KiB
JavaScript
import { app, BrowserWindow, shell } from 'electron';
|
|
import { fileURLToPath } from 'url';
|
|
import path from 'path';
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
|
|
let mainWindow;
|
|
|
|
function createWindow() {
|
|
mainWindow = new BrowserWindow({
|
|
width: 1440,
|
|
height: 900,
|
|
minWidth: 1024,
|
|
minHeight: 640,
|
|
webPreferences: {
|
|
webSecurity: false, // Allow file:// origin to call external APIs
|
|
contextIsolation: true,
|
|
nodeIntegration: false,
|
|
},
|
|
titleBarStyle: 'hiddenInset',
|
|
backgroundColor: '#0d0d0d',
|
|
show: false,
|
|
title: 'Open Higgsfield AI',
|
|
});
|
|
|
|
const indexPath = path.join(__dirname, '../dist/index.html');
|
|
mainWindow.loadFile(indexPath);
|
|
|
|
// Open external links in the system browser
|
|
mainWindow.webContents.setWindowOpenHandler(({ url }) => {
|
|
shell.openExternal(url);
|
|
return { action: 'deny' };
|
|
});
|
|
|
|
mainWindow.once('ready-to-show', () => {
|
|
mainWindow.show();
|
|
});
|
|
|
|
mainWindow.on('closed', () => {
|
|
mainWindow = null;
|
|
});
|
|
}
|
|
|
|
app.whenReady().then(() => {
|
|
createWindow();
|
|
|
|
app.on('activate', () => {
|
|
if (BrowserWindow.getAllWindows().length === 0) {
|
|
createWindow();
|
|
}
|
|
});
|
|
});
|
|
|
|
app.on('window-all-closed', () => {
|
|
if (process.platform !== 'darwin') {
|
|
app.quit();
|
|
}
|
|
});
|