Skip to content

Commit

Permalink
browserview
Browse files Browse the repository at this point in the history
  • Loading branch information
liuliu-dev committed Sep 20, 2024
1 parent 3d7c212 commit dece2a3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
15 changes: 15 additions & 0 deletions main/background.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from "path";
import {
app,
BrowserView,
BrowserWindow,
ipcMain,
Menu,
Expand Down Expand Up @@ -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);
})
4 changes: 2 additions & 2 deletions web/hooks/useElectronMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit dece2a3

Please sign in to comment.