mirror of
https://github.com/Anil-matcha/Open-Generative-AI.git
synced 2026-05-07 01:17:18 +00:00
- Add electron:build:linux script and AppImage + .deb targets in package.json - Fix Electron main.js: ESM → CommonJS, remove macOS-only titleBarStyle on Linux - Fix createInlineInstructions undefined error in ImageStudio.js - Fix Cinema Studio asset paths (absolute → relative) for Electron file:// protocol - Add AppArmor profile for Ubuntu 24.04+ user namespace sandbox fix - Add Ubuntu install docs and sandbox workaround to README
72 lines
2 KiB
JavaScript
72 lines
2 KiB
JavaScript
const { app, BrowserWindow, shell } = require('electron');
|
|
const path = require('path');
|
|
|
|
// Ubuntu 24.04+ sets kernel.apparmor_restrict_unprivileged_userns=1 which
|
|
// blocks Chromium's user namespace sandbox. The .deb package ships an AppArmor
|
|
// profile that grants the permission cleanly. When running the AppImage on an
|
|
// affected system, run once: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
|
|
// or pass --no-sandbox on the command line.
|
|
if (process.platform === 'linux') {
|
|
app.commandLine.appendSwitch('disable-dev-shm-usage');
|
|
}
|
|
|
|
let mainWindow;
|
|
|
|
function createWindow() {
|
|
const isMac = process.platform === 'darwin';
|
|
|
|
mainWindow = new BrowserWindow({
|
|
width: 1440,
|
|
height: 900,
|
|
minWidth: 1024,
|
|
minHeight: 640,
|
|
webPreferences: {
|
|
webSecurity: false,
|
|
contextIsolation: true,
|
|
nodeIntegration: false,
|
|
},
|
|
...(isMac ? { titleBarStyle: 'hiddenInset' } : {}),
|
|
backgroundColor: '#0d0d0d',
|
|
show: false,
|
|
title: 'Open Generative AI',
|
|
});
|
|
|
|
const indexPath = path.join(__dirname, '../dist/index.html');
|
|
mainWindow.loadFile(indexPath).catch((err) => {
|
|
console.error('Failed to load index.html:', err);
|
|
mainWindow.show();
|
|
});
|
|
|
|
mainWindow.webContents.on('did-fail-load', (event, code, desc) => {
|
|
console.error('did-fail-load:', code, desc);
|
|
});
|
|
|
|
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();
|
|
}
|
|
});
|