Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

fix: improve Electron security and functionality

benzntech5e72cd34f0bc
diff --git a/electron/main.js b/electron/main.js
index 4d5dddf12a..7edd51c0dc 100644
--- a/electron/main.js
+++ b/electron/main.js
@@ -10,6 +10,21 @@ const path = require('path');
const { spawn } = require('child_process');
const fs = require('fs');
+// Single instance lock - prevent multiple instances
+const gotTheLock = app.requestSingleInstanceLock();
+if (!gotTheLock) {
+ app.quit();
+ process.exit(0);
+}
+
+app.on('second-instance', () => {
+ if (mainWindow) {
+ if (mainWindow.isMinimized()) mainWindow.restore();
+ mainWindow.show();
+ mainWindow.focus();
+ }
+});
+
// Environment detection
const isDev = process.env.NODE_ENV === 'development' || !app.isPackaged;
const isProduction = !isDev;
@@ -224,7 +239,14 @@ function setupIpcHandlers() {
// Open external URL
ipcMain.handle('open-external', (event, url) => {
- shell.openExternal(url);
+ try {
+ const parsedUrl = new URL(url);
+ if (['http:', 'https:'].includes(parsedUrl.protocol)) {
+ shell.openExternal(url);
+ }
+ } catch {
+ console.error('Invalid URL:', url);
+ }
});
// Get data directory
@@ -240,6 +262,25 @@ function setupIpcHandlers() {
startNextServer();
return { success: true };
});
+
+ // Window controls
+ ipcMain.on('window-minimize', () => {
+ mainWindow?.minimize();
+ });
+
+ ipcMain.on('window-maximize', () => {
+ if (mainWindow) {
+ if (mainWindow.isMaximized()) {
+ mainWindow.unmaximize();
+ } else {
+ mainWindow.maximize();
+ }
+ }
+ });
+
+ ipcMain.on('window-close', () => {
+ mainWindow?.close();
+ });
}
// App lifecycle events
diff --git a/electron/package.json b/electron/package.json
index 6d698b7ca4..eefc5dd577 100644
--- a/electron/package.json
+++ b/electron/package.json
@@ -24,6 +24,12 @@
"appId": "online.omniroute.desktop",
"productName": "OmniRoute",
"copyright": "Copyright © 2025 OmniRoute",
+ "protocols": [
+ {
+ "name": "OmniRoute",
+ "schemes": ["omniroute"]
+ }
+ ],
"directories": {
"output": "dist-electron",
"buildResources": "assets"