mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-04-28 01:46:23 +02:00
open links in user browser
This commit is contained in:
parent
09604f3738
commit
ccb2e94fac
1 changed files with 19 additions and 1 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { app, BrowserWindow, protocol, net } from "electron";
|
||||
import { app, BrowserWindow, protocol, net, shell } from "electron";
|
||||
import path from "node:path";
|
||||
import { setupIpcHandlers, startRunsWatcher, startWorkspaceWatcher, stopWorkspaceWatcher } from "./ipc.js";
|
||||
import { fileURLToPath, pathToFileURL } from "node:url";
|
||||
|
|
@ -80,6 +80,24 @@ function createWindow() {
|
|||
},
|
||||
});
|
||||
|
||||
// Open external links in system browser (not sandboxed Electron window)
|
||||
// This handles window.open() and target="_blank" links
|
||||
win.webContents.setWindowOpenHandler(({ url }) => {
|
||||
// Open all URLs in system browser
|
||||
shell.openExternal(url);
|
||||
return { action: 'deny' }; // Prevent Electron from opening a new window
|
||||
});
|
||||
|
||||
// Handle navigation to external URLs (e.g., clicking a link without target="_blank")
|
||||
win.webContents.on('will-navigate', (event, url) => {
|
||||
// Allow internal navigation (app protocol or dev server)
|
||||
const isInternal = url.startsWith('app://') || url.startsWith('http://localhost:5173');
|
||||
if (!isInternal) {
|
||||
event.preventDefault();
|
||||
shell.openExternal(url);
|
||||
}
|
||||
});
|
||||
|
||||
// #region agent log
|
||||
const loadURL = app.isPackaged ? 'app://./' : 'http://localhost:5173';
|
||||
fetch('http://127.0.0.1:7242/ingest/dd33b297-24f6-4846-82f9-02599308a13a',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'main.ts:65',message:'createWindow called',data:{isPackaged:app.isPackaged,loadURL,preloadPath},timestamp:Date.now(),sessionId:'debug-session',runId:'run1',hypothesisId:'E'})}).catch(()=>{});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue