mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-22 12:36:24 +08:00
feat: plugin system with isolated bundles (#2660)
(cherry picked from commit 94d20f1bdc)
This commit is contained in:
@@ -1,10 +1,17 @@
|
||||
import { join } from 'node:path';
|
||||
|
||||
import { app, BrowserWindow, nativeTheme } from 'electron';
|
||||
|
||||
import type { NamespaceHandlers } from '../type';
|
||||
import { isMacOS } from '../utils';
|
||||
import { getMetaData } from './get-meta-data';
|
||||
import { getGoogleOauthCode } from './google-auth';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const handlers = require(join(
|
||||
process.env.PLUGIN_DIR ?? '../../plugins',
|
||||
'./bookmark-block/server'
|
||||
)) as NamespaceHandlers;
|
||||
|
||||
export const uiHandlers = {
|
||||
handleThemeChange: async (_, theme: (typeof nativeTheme)['themeSource']) => {
|
||||
nativeTheme.themeSource = theme;
|
||||
@@ -40,11 +47,5 @@ export const uiHandlers = {
|
||||
getGoogleOauthCode: async () => {
|
||||
return getGoogleOauthCode();
|
||||
},
|
||||
getBookmarkDataByLink: async (_, url: string) => {
|
||||
return getMetaData(url, {
|
||||
shouldReGetHTML: metaData => {
|
||||
return !metaData.title && !metaData.description;
|
||||
},
|
||||
});
|
||||
},
|
||||
...handlers,
|
||||
} satisfies NamespaceHandlers;
|
||||
|
||||
Reference in New Issue
Block a user