Skip to content

Commit

Permalink
fix(electron): add dedicated api for opening external links in the de…
Browse files Browse the repository at this point in the history
…fault browser (#6166)
  • Loading branch information
pengx17 committed Mar 18, 2024
1 parent 8301d82 commit 386bd03
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/frontend/core/src/utils/cloud-utils.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { apis } from '@affine/electron-api';
import {
generateRandUTF16Chars,
getBaseUrl,
Expand Down Expand Up @@ -62,13 +63,12 @@ export const signInCloud = async (
.catch(err => onRejectHandleTrace(err, traceParams));
} else if (OAuthProviderType[provider]) {
if (environment.isDesktop) {
open(
await apis?.ui.openExternal(
`${
runtimeConfig.serverUrlPrefix
}/desktop-signin?provider=${provider}&redirect_uri=${buildRedirectUri(
'/open-app/signin-redirect'
)}`,
'_target'
)}`
);
} else {
location.href = `${
Expand Down
5 changes: 4 additions & 1 deletion packages/frontend/electron/src/main/ui/handlers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { app, nativeTheme } from 'electron';
import { app, nativeTheme, shell } from 'electron';
import { getLinkPreview } from 'link-preview-js';

import { isMacOS } from '../../shared/utils';
Expand Down Expand Up @@ -122,4 +122,7 @@ export const uiHandlers = {
};
}
},
openExternal(_, url: string) {
return shell.openExternal(url);
},
} satisfies NamespaceHandlers;

0 comments on commit 386bd03

Please sign in to comment.