fix: ws prefix url in electron (#1896)

This commit is contained in:
Peng Xiao
2023-04-12 22:11:47 +08:00
committed by GitHub
parent 25d7f7c848
commit 95aa86cdf0
17 changed files with 237 additions and 261 deletions

View File

@@ -167,9 +167,16 @@ export function createAffineAuth(prefix = '/') {
}
let provider: AuthProvider;
switch (method) {
case SignMethod.Google:
provider = new GoogleAuthProvider();
case SignMethod.Google: {
const googleProvider = new GoogleAuthProvider();
// make sure the user has a chance to select an account
// https://developers.google.com/identity/openid-connect/openid-connect#prompt
googleProvider.setCustomParameters({
prompt: 'select_account',
});
provider = googleProvider;
break;
}
case SignMethod.GitHub:
provider = new GithubAuthProvider();
break;

View File

@@ -1,4 +1,5 @@
import { DebugLogger } from '@affine/debug';
import { websocketPrefixUrl } from '@affine/env/api';
import {
workspaceDetailSchema,
workspaceSchema,
@@ -61,11 +62,7 @@ export function createAffineGlobalChannel(
let dispose: Disposable | undefined = undefined;
const apis = {
connect: () => {
client = new WebsocketClient(
`${window.location.protocol === 'https:' ? 'wss' : 'ws'}://${
window.location.host
}/api/global/sync`
);
client = new WebsocketClient(websocketPrefixUrl + '/api/global/sync/');
client.connect(handleMessage);
dispose = storageChangeSlot.on(() => {
apis.disconnect();

View File

@@ -1,4 +1,4 @@
import { config } from '@affine/env';
import { config, websocketPrefixUrl } from '@affine/env';
import { KeckProvider } from '@affine/workspace/affine/keck';
import {
getLoginStorage,
@@ -41,11 +41,8 @@ const createAffineWebSocketProvider = (
apis.disconnect();
apis.connect();
});
const wsUrl = `${
window.location.protocol === 'https:' ? 'wss' : 'ws'
}://${window.location.host}/api/sync/`;
webSocketProvider = new KeckProvider(
wsUrl,
websocketPrefixUrl + '/api/sync/',
blockSuiteWorkspace.id,
blockSuiteWorkspace.doc,
{