Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): use openExternal in electron #8323

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`);
}
}
Loading