mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-22 19:53:48 +08:00
fix(electron): add dedicated api for opening external links in the default browser (#6166)
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import { apis } from '@affine/electron-api';
|
||||||
import {
|
import {
|
||||||
generateRandUTF16Chars,
|
generateRandUTF16Chars,
|
||||||
getBaseUrl,
|
getBaseUrl,
|
||||||
@@ -62,13 +63,12 @@ export const signInCloud = async (
|
|||||||
.catch(err => onRejectHandleTrace(err, traceParams));
|
.catch(err => onRejectHandleTrace(err, traceParams));
|
||||||
} else if (OAuthProviderType[provider]) {
|
} else if (OAuthProviderType[provider]) {
|
||||||
if (environment.isDesktop) {
|
if (environment.isDesktop) {
|
||||||
open(
|
await apis?.ui.openExternal(
|
||||||
`${
|
`${
|
||||||
runtimeConfig.serverUrlPrefix
|
runtimeConfig.serverUrlPrefix
|
||||||
}/desktop-signin?provider=${provider}&redirect_uri=${buildRedirectUri(
|
}/desktop-signin?provider=${provider}&redirect_uri=${buildRedirectUri(
|
||||||
'/open-app/signin-redirect'
|
'/open-app/signin-redirect'
|
||||||
)}`,
|
)}`
|
||||||
'_target'
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
location.href = `${
|
location.href = `${
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { app, nativeTheme } from 'electron';
|
import { app, nativeTheme, shell } from 'electron';
|
||||||
import { getLinkPreview } from 'link-preview-js';
|
import { getLinkPreview } from 'link-preview-js';
|
||||||
|
|
||||||
import { isMacOS } from '../../shared/utils';
|
import { isMacOS } from '../../shared/utils';
|
||||||
@@ -122,4 +122,7 @@ export const uiHandlers = {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
openExternal(_, url: string) {
|
||||||
|
return shell.openExternal(url);
|
||||||
|
},
|
||||||
} satisfies NamespaceHandlers;
|
} satisfies NamespaceHandlers;
|
||||||
|
|||||||
Reference in New Issue
Block a user