mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
refactor(electron): create electron api package (#5334)
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
||||
resolveGlobalLoadingEventAtom,
|
||||
} from '@affine/component/global-loading';
|
||||
import { pushNotificationAtom } from '@affine/component/notification-center';
|
||||
import { apis } from '@affine/electron-api';
|
||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
||||
import {
|
||||
HtmlTransformer,
|
||||
@@ -49,7 +50,7 @@ async function exportHandler({ page, type }: ExportHandlerOptions) {
|
||||
break;
|
||||
case 'pdf':
|
||||
if (environment.isDesktop && page.meta.mode === 'page') {
|
||||
await window.apis?.export.savePDFFileAs(
|
||||
await apis?.export.savePDFFileAs(
|
||||
(page.root as PageBlockModel).title.toString()
|
||||
);
|
||||
} else {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { apis } from '@affine/electron-api';
|
||||
import { assertExists } from '@blocksuite/global/utils';
|
||||
import {
|
||||
type AppConfigSchema,
|
||||
AppConfigStorage,
|
||||
@@ -13,11 +15,13 @@ class AppConfigProxy {
|
||||
value: AppConfigSchema = defaultAppConfig;
|
||||
|
||||
async getSync(): Promise<AppConfigSchema> {
|
||||
return (this.value = await window.apis.configStorage.get());
|
||||
assertExists(apis);
|
||||
return (this.value = await apis.configStorage.get());
|
||||
}
|
||||
|
||||
async setSync(): Promise<void> {
|
||||
await window.apis.configStorage.set(this.value);
|
||||
assertExists(apis);
|
||||
await apis.configStorage.set(this.value);
|
||||
}
|
||||
|
||||
get(): AppConfigSchema {
|
||||
|
||||
Reference in New Issue
Block a user