Skip to content

Commit

Permalink
fix(core): use openExternal in electron (#8323)
Browse files Browse the repository at this point in the history
  • Loading branch information
forehalo committed Sep 20, 2024
1 parent 8d4cc6a commit ec7c630
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/frontend/core/src/utils/popup.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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`);
}
}

0 comments on commit ec7c630

Please sign in to comment.