mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-06 08:50:50 +08:00
feat(ios): add some apis for native (#9173)
This commit is contained in:
@@ -9,6 +9,7 @@ import { configureCommonModules } from '@affine/core/modules';
|
|||||||
import {
|
import {
|
||||||
AuthService,
|
AuthService,
|
||||||
DefaultServerService,
|
DefaultServerService,
|
||||||
|
ServersService,
|
||||||
ValidatorProvider,
|
ValidatorProvider,
|
||||||
WebSocketAuthProvider,
|
WebSocketAuthProvider,
|
||||||
} from '@affine/core/modules/cloud';
|
} from '@affine/core/modules/cloud';
|
||||||
@@ -22,6 +23,7 @@ import {
|
|||||||
configureBrowserWorkspaceFlavours,
|
configureBrowserWorkspaceFlavours,
|
||||||
configureIndexedDBWorkspaceEngineStorageProvider,
|
configureIndexedDBWorkspaceEngineStorageProvider,
|
||||||
} from '@affine/core/modules/workspace-engine';
|
} from '@affine/core/modules/workspace-engine';
|
||||||
|
import { I18n } from '@affine/i18n';
|
||||||
import { App as CapacitorApp } from '@capacitor/app';
|
import { App as CapacitorApp } from '@capacitor/app';
|
||||||
import { Browser } from '@capacitor/browser';
|
import { Browser } from '@capacitor/browser';
|
||||||
import { Haptics } from '@capacitor/haptics';
|
import { Haptics } from '@capacitor/haptics';
|
||||||
@@ -30,6 +32,7 @@ import {
|
|||||||
Framework,
|
Framework,
|
||||||
FrameworkRoot,
|
FrameworkRoot,
|
||||||
getCurrentStore,
|
getCurrentStore,
|
||||||
|
GlobalContextService,
|
||||||
LifecycleService,
|
LifecycleService,
|
||||||
} from '@toeverything/infra';
|
} from '@toeverything/infra';
|
||||||
import { Suspense } from 'react';
|
import { Suspense } from 'react';
|
||||||
@@ -111,6 +114,21 @@ framework.impl(HapticProvider, {
|
|||||||
});
|
});
|
||||||
const frameworkProvider = framework.provider();
|
const frameworkProvider = framework.provider();
|
||||||
|
|
||||||
|
// ------ some apis for native ------
|
||||||
|
(window as any).getCurrentServerBaseUrl = () => {
|
||||||
|
const globalContextService = frameworkProvider.get(GlobalContextService);
|
||||||
|
const currentServerId = globalContextService.globalContext.serverId.get();
|
||||||
|
const serversService = frameworkProvider.get(ServersService);
|
||||||
|
const defaultServerService = frameworkProvider.get(DefaultServerService);
|
||||||
|
const currentServer =
|
||||||
|
(currentServerId ? serversService.server$(currentServerId).value : null) ??
|
||||||
|
defaultServerService.server;
|
||||||
|
return currentServer.baseUrl;
|
||||||
|
};
|
||||||
|
(window as any).getCurrentI18nLocale = () => {
|
||||||
|
return I18n.language;
|
||||||
|
};
|
||||||
|
|
||||||
// setup application lifecycle events, and emit application start event
|
// setup application lifecycle events, and emit application start event
|
||||||
window.addEventListener('focus', () => {
|
window.addEventListener('focus', () => {
|
||||||
frameworkProvider.get(LifecycleService).applicationFocus();
|
frameworkProvider.get(LifecycleService).applicationFocus();
|
||||||
|
|||||||
Reference in New Issue
Block a user