mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-15 09:06:19 +08:00
bb8bfd0c9e
(cherry picked from commit 94d20f1bdc)
52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
import { join } from 'node:path';
|
|
|
|
import { app, BrowserWindow, nativeTheme } from 'electron';
|
|
|
|
import type { NamespaceHandlers } from '../type';
|
|
import { isMacOS } from '../utils';
|
|
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;
|
|
},
|
|
handleSidebarVisibilityChange: async (_, visible: boolean) => {
|
|
if (isMacOS()) {
|
|
const windows = BrowserWindow.getAllWindows();
|
|
windows.forEach(w => {
|
|
// hide window buttons when sidebar is not visible
|
|
w.setWindowButtonVisibility(visible);
|
|
});
|
|
}
|
|
},
|
|
handleMinimizeApp: async () => {
|
|
const windows = BrowserWindow.getAllWindows();
|
|
windows.forEach(w => {
|
|
w.minimize();
|
|
});
|
|
},
|
|
handleMaximizeApp: async () => {
|
|
const windows = BrowserWindow.getAllWindows();
|
|
windows.forEach(w => {
|
|
if (w.isMaximized()) {
|
|
w.unmaximize();
|
|
} else {
|
|
w.maximize();
|
|
}
|
|
});
|
|
},
|
|
handleCloseApp: async () => {
|
|
app.quit();
|
|
},
|
|
getGoogleOauthCode: async () => {
|
|
return getGoogleOauthCode();
|
|
},
|
|
...handlers,
|
|
} satisfies NamespaceHandlers;
|