mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-25 04:56:02 +08:00
fix: window control not work (#2790)
(cherry picked from commit 9fd4818d81)
This commit is contained in:
@@ -11,8 +11,14 @@ import { affinePluginsAtom } from '@toeverything/plugin-infra/manager';
|
|||||||
import type { PluginUIAdapter } from '@toeverything/plugin-infra/type';
|
import type { PluginUIAdapter } from '@toeverything/plugin-infra/type';
|
||||||
import { useAtom, useAtomValue } from 'jotai';
|
import { useAtom, useAtomValue } from 'jotai';
|
||||||
import type { FC, HTMLAttributes, PropsWithChildren, ReactNode } from 'react';
|
import type { FC, HTMLAttributes, PropsWithChildren, ReactNode } from 'react';
|
||||||
import { forwardRef, memo, useEffect, useMemo, useState } from 'react';
|
import {
|
||||||
import { noop } from 'rxjs';
|
forwardRef,
|
||||||
|
memo,
|
||||||
|
useCallback,
|
||||||
|
useEffect,
|
||||||
|
useMemo,
|
||||||
|
useState,
|
||||||
|
} from 'react';
|
||||||
|
|
||||||
import { guideDownloadClientTipAtom } from '../../../atoms/guide';
|
import { guideDownloadClientTipAtom } from '../../../atoms/guide';
|
||||||
import { contentLayoutAtom } from '../../../atoms/layout';
|
import { contentLayoutAtom } from '../../../atoms/layout';
|
||||||
@@ -100,26 +106,41 @@ const HeaderRightItems: Record<HeaderRightItemName, HeaderItem> = {
|
|||||||
},
|
},
|
||||||
[HeaderRightItemName.WindowsAppControls]: {
|
[HeaderRightItemName.WindowsAppControls]: {
|
||||||
Component: () => {
|
Component: () => {
|
||||||
|
const handleMinimizeApp = useCallback(() => {
|
||||||
|
window.apis?.ui.handleMinimizeApp().catch(err => {
|
||||||
|
console.error(err);
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
const handleMaximizeApp = useCallback(() => {
|
||||||
|
window.apis?.ui.handleMaximizeApp().catch(err => {
|
||||||
|
console.error(err);
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
const handleCloseApp = useCallback(() => {
|
||||||
|
window.apis?.ui.handleCloseApp().catch(err => {
|
||||||
|
console.error(err);
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
return (
|
return (
|
||||||
<div className={styles.windowAppControlsWrapper}>
|
<div className={styles.windowAppControlsWrapper}>
|
||||||
<button
|
<button
|
||||||
data-type="minimize"
|
data-type="minimize"
|
||||||
className={styles.windowAppControl}
|
className={styles.windowAppControl}
|
||||||
onClick={window.apis?.ui.handleMinimizeApp ?? noop}
|
onClick={handleMinimizeApp}
|
||||||
>
|
>
|
||||||
<MinusIcon />
|
<MinusIcon />
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
data-type="maximize"
|
data-type="maximize"
|
||||||
className={styles.windowAppControl}
|
className={styles.windowAppControl}
|
||||||
onClick={window.apis?.ui.handleMaximizeApp ?? noop}
|
onClick={handleMaximizeApp}
|
||||||
>
|
>
|
||||||
<RoundedRectangleIcon />
|
<RoundedRectangleIcon />
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
data-type="close"
|
data-type="close"
|
||||||
className={styles.windowAppControl}
|
className={styles.windowAppControl}
|
||||||
onClick={window.apis?.ui.handleCloseApp ?? noop}
|
onClick={handleCloseApp}
|
||||||
>
|
>
|
||||||
<CloseIcon />
|
<CloseIcon />
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user