diff --git a/main/background.ts b/main/background.ts index 9cfbee6d..4f022bb4 100644 --- a/main/background.ts +++ b/main/background.ts @@ -1,6 +1,7 @@ import path from "path"; import { app, + BrowserView, BrowserWindow, ipcMain, Menu, @@ -143,3 +144,17 @@ ipcMain.handle("api-config", async () => { }; return cfg; }); + +ipcMain.handle("open-new-tab", async (event, arg) => { + const view=new BrowserWindow({ + webPreferences: { + preload: path.join(__dirname, "preload.js"), + }, + }); + mainWindow.addTabbedWindow(view); + + const port = process.argv[2]; + const url=isProd?`app://./${arg}`:`http://localhost:${port}${arg}`; + console.log(url); + view.loadURL(url); +}) \ No newline at end of file diff --git a/web/hooks/useElectronMenu.ts b/web/hooks/useElectronMenu.ts index ed384d50..978a0e71 100644 --- a/web/hooks/useElectronMenu.ts +++ b/web/hooks/useElectronMenu.ts @@ -28,8 +28,8 @@ export default function useElectronMenu(params: DatabasePageParams) { break; } case "commit-graph": { - const { href, as } = commitGraph(paramsWithRef); - router.push(href, as).catch(console.error); + const { as } = commitGraph(paramsWithRef); + window.ipc.invoke("open-new-tab",as); break; } case "schema-diagram": {