feat: init ios-bridge

This commit is contained in:
EYHN
2024-04-25 16:50:21 +08:00
parent 4ec89ebd69
commit b2678b8448
15 changed files with 245 additions and 19 deletions
@@ -129,23 +129,13 @@ export class AuthService extends Service {
}
async signInPassword(credential: { email: string; password: string }) {
const searchParams = new URLSearchParams();
const redirectUri = new URL(location.href);
if (environment.isDesktop) {
redirectUri.pathname = this.buildRedirectUri('/open-app/signin-redirect');
}
searchParams.set('redirect_uri', redirectUri.toString());
const res = await this.fetchService.fetch(
'/api/auth/sign-in?' + searchParams.toString(),
{
method: 'POST',
body: JSON.stringify(credential),
headers: {
'content-type': 'application/json',
},
}
);
const res = await this.fetchService.fetch('/api/auth/sign-in', {
method: 'POST',
body: JSON.stringify(credential),
headers: {
'content-type': 'application/json',
},
});
if (!res.ok) {
throw new Error('Failed to sign in');
}
@@ -5,6 +5,9 @@ import { fromPromise, Service } from '@toeverything/infra';
import { BackendError, NetworkError } from '../error';
export function getAffineCloudBaseUrl(): string {
if ((globalThis as any)['__AFFINE_CLOUD_BASE_URL__']) {
return (globalThis as any)['__AFFINE_CLOUD_BASE_URL__'];
}
if (environment.isDesktop) {
return runtimeConfig.serverUrlPrefix;
}