From ec7c63019f791c685af2e2123088bf391043725f Mon Sep 17 00:00:00 2001 From: forehalo Date: Fri, 20 Sep 2024 07:05:12 +0000 Subject: [PATCH] fix(core): use openExternal in electron (#8323) --- packages/frontend/core/src/utils/popup.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/frontend/core/src/utils/popup.ts b/packages/frontend/core/src/utils/popup.ts index 528d629e33..b1c46cef56 100644 --- a/packages/frontend/core/src/utils/popup.ts +++ b/packages/frontend/core/src/utils/popup.ts @@ -1,3 +1,8 @@ +import { DebugLogger } from '@affine/debug'; +import { apis } from '@affine/electron-api'; + +const logger = new DebugLogger('popup'); + export function popupWindow(target: string) { target = /^https?:\/\//.test(target) ? target @@ -14,5 +19,11 @@ export function popupWindow(target: string) { url = builder.toString(); } - return window.open(url, '_blank', `noreferrer noopener`); + if (BUILD_CONFIG.isElectron) { + apis?.ui.openExternal(url).catch(e => { + logger.error('Failed to open external URL', e); + }); + } else { + window.open(url, '_blank', `noreferrer noopener`); + } }