返回 AiToEarn
WindowControlButtons.tsx
根目录 / project / aitoearn-electron / src / components / WindowControlButtons / WindowControlButtons.tsx
1 import { ForwardedRef, forwardRef, memo, useEffect, useState } from 'react';
2 import styles from './windowControlButtons.module.scss';
3 import {
4 BorderOutlined,
5 CloseOutlined,
6 MinusOutlined,
7 } from '@ant-design/icons';
8 import { ipcAppInfo } from '../../icp/app';
9
10 export interface IWindowcontrolbuttonsRef {}
11
12 export interface IWindowcontrolbuttonsProps {}
13
14 const Windowcontrolbuttons = memo(
15 forwardRef(
16 (
17 {}: IWindowcontrolbuttonsProps,
18 ref: ForwardedRef<IWindowcontrolbuttonsRef>,
19 ) => {
20 const [platform, setPlatform] = useState('');
21
22 useEffect(() => {
23 ipcAppInfo().then((res) => {
24 setPlatform(res.platform);
25 });
26 }, []);
27
28 if (platform !== 'win32') return;
29
30 return (
31 <div className={styles.windowControlButtons}>
32 <div
33 className={styles.minimize}
34 onClick={() => {
35 window.ipcRenderer.invoke('window-minimize');
36 }}
37 >
38 <MinusOutlined />
39 </div>
40 <div
41 className={styles.maximize}
42 onClick={() => {
43 window.ipcRenderer.invoke('window-maximize');
44 }}
45 >
46 <BorderOutlined />
47 </div>
48 <div
49 className={styles.close}
50 onClick={() => {
51 window.ipcRenderer.invoke('window-close');
52 }}
53 >
54 <CloseOutlined />
55 </div>
56 </div>
57 );
58 },
59 ),
60 );
61 Windowcontrolbuttons.displayName = 'Windowcontrolbuttons';
62
63 export default Windowcontrolbuttons;
64
64 lines Plain Text