From 24bf1beac8451c4d87a9e75a55bc5cc163a446a0 Mon Sep 17 00:00:00 2001 From: pengx17 Date: Thu, 12 Sep 2024 03:20:19 +0000 Subject: [PATCH] fix(electron): devtools open in detach mode (#8200) fix AF-1380 --- .../electron/src/main/windows-manager/main-window.ts | 4 +++- .../electron/src/main/windows-manager/tab-views.ts | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/frontend/electron/src/main/windows-manager/main-window.ts b/packages/frontend/electron/src/main/windows-manager/main-window.ts index 076cff77c2..a05eddf885 100644 --- a/packages/frontend/electron/src/main/windows-manager/main-window.ts +++ b/packages/frontend/electron/src/main/windows-manager/main-window.ts @@ -258,7 +258,9 @@ export async function openUrlInHiddenWindow(urlObj: URL) { }); if (environment.isDebug) { - win.webContents.openDevTools(); + win.webContents.openDevTools({ + mode: 'detach', + }); } win.on('close', e => { diff --git a/packages/frontend/electron/src/main/windows-manager/tab-views.ts b/packages/frontend/electron/src/main/windows-manager/tab-views.ts index 591d9044e3..14c0913bf4 100644 --- a/packages/frontend/electron/src/main/windows-manager/tab-views.ts +++ b/packages/frontend/electron/src/main/windows-manager/tab-views.ts @@ -815,7 +815,9 @@ export class WebContentViewsManager { view.webContents.loadURL(shellViewUrl).catch(logger.error); if (isDev) { - view.webContents.openDevTools(); + view.webContents.openDevTools({ + mode: 'detach', + }); } } @@ -999,13 +1001,17 @@ export const showDevTools = (id?: string) => { getCustomThemeWindow() .then(w => { if (w && w.isFocused()) { - w.webContents.openDevTools(); + w.webContents.openDevTools({ + mode: 'detach', + }); } else { const view = id ? WebContentViewsManager.instance.getViewById(id) : WebContentViewsManager.instance.activeWorkbenchView; if (view) { - view.webContents.openDevTools(); + view.webContents.openDevTools({ + mode: 'detach', + }); } } })