From 2f7cad895226e9994109b5def00d1c8e9e086630 Mon Sep 17 00:00:00 2001 From: yj <1336058017@qq.com> Date: Thu, 25 Jul 2024 10:12:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.tsx | 5 +- src/components/Operation/index.module.scss | 14 ----- src/components/Operation/index.tsx | 55 ++---------------- src/components/QuitTips/index.module.scss | 13 +++++ src/components/QuitTips/index.tsx | 65 ++++++++++++++++++++++ 5 files changed, 87 insertions(+), 65 deletions(-) create mode 100644 src/components/QuitTips/index.module.scss create mode 100644 src/components/QuitTips/index.tsx diff --git a/src/App.tsx b/src/App.tsx index f2c55a9..90c8c2b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -17,12 +17,14 @@ import * as CryptoJS from 'crypto-js'; import { PostLogin } from "@/api/Login"; import { startSignalr } from '@/utils/package/signalr'; import agora from "@/utils/package/agora"; +import QuitTips from "@/components/QuitTips"; const App: React.FC = () => { const navigate = useNavigate(); const { state } = useLocation(); const joinMeetingModalRef = useRef(); const updateModalRef = useRef(); + const quitTipsRef = useRef(); const [_windowSize, setWindowSize] = useState({ width: window.innerWidth, height: window.innerHeight, @@ -116,7 +118,7 @@ const App: React.FC = () => { onReconnected(async () => { storage.setItem('reconnect', true) }) - window.electron.onUpdate((data:any) => { + window.electron.onUpdate((data: any) => { updateModalRef.current.changeModal(data) }) }, []) @@ -181,6 +183,7 @@ const App: React.FC = () => { + ) } diff --git a/src/components/Operation/index.module.scss b/src/components/Operation/index.module.scss index fb119fe..a57c948 100644 --- a/src/components/Operation/index.module.scss +++ b/src/components/Operation/index.module.scss @@ -25,17 +25,3 @@ } } } - -.isCloseModal { - .isCloseModalContent { - display: flex; - align-items: center; - margin: 10px 0; - } - - .isCloseModalFooter { - display: flex; - align-items: center; - justify-content: space-between; - } -} \ No newline at end of file diff --git a/src/components/Operation/index.tsx b/src/components/Operation/index.tsx index ab34d06..7bc5477 100644 --- a/src/components/Operation/index.tsx +++ b/src/components/Operation/index.tsx @@ -1,9 +1,8 @@ import styles from '@/components/Operation/index.module.scss' import { storage } from '@/utils'; import ImageUrl from '@/utils/package/ImageUrl'; -import { InfoCircleOutlined } from '@ant-design/icons'; -import { Button, Checkbox, Modal, Radio } from 'antd'; -import { useEffect, useState } from "react"; +import { useEffect, useState, useRef } from "react"; +import QuitTips from '../QuitTips'; type OperationKeyType = 'minimize' | 'quit' | 'maximize' | 'unmaximize'; type OperationType = { icon: string; @@ -13,6 +12,7 @@ type OperationType = { show: boolean; } const Operation: React.FC = () => { + const quitTipsRef = useRef() const [_windowSize, setWindowSize] = useState({ width: window.innerWidth, height: window.innerHeight, @@ -52,14 +52,11 @@ const Operation: React.FC = () => { if (storage.getItem('isTips') === 'true') { window.electron.setViewStatus(key) } else { - setIsCloseModal(true) + quitTipsRef.current.changeModal() } }, show: true, },]) - const [isCloseModal, setIsCloseModal] = useState(false); - const [isTips, setIsTips] = useState(false); - const [optionsValue, setOperation] = useState('minimize'); useEffect(() => { getIsMaximized() const handleResize = () => { @@ -105,49 +102,7 @@ const Operation: React.FC = () => { }) } - setIsCloseModal(false)} - centered - width={'380px'} - > -
-
- -
- 您点击了关闭按钮,您是想: - { - setOperation(e.target.value); - }} value={optionsValue}> - 最小化到系统托盘区,不退出程序。 - 退出程序。 - -
-
-
- { - setIsTips(e.target.checked) - storage.setItem('isTips', e.target.checked) - }} defaultChecked={isTips}>不再提示 -
- - -
-
-
-
+ ) } diff --git a/src/components/QuitTips/index.module.scss b/src/components/QuitTips/index.module.scss new file mode 100644 index 0000000..4e6791b --- /dev/null +++ b/src/components/QuitTips/index.module.scss @@ -0,0 +1,13 @@ +.isCloseModal { + .isCloseModalContent { + display: flex; + align-items: center; + margin: 10px 0; + } + + .isCloseModalFooter { + display: flex; + align-items: center; + justify-content: space-between; + } +} \ No newline at end of file diff --git a/src/components/QuitTips/index.tsx b/src/components/QuitTips/index.tsx new file mode 100644 index 0000000..8115ebc --- /dev/null +++ b/src/components/QuitTips/index.tsx @@ -0,0 +1,65 @@ +import styles from '@/components/QuitTips/index.module.scss' +import { storage } from '@/utils'; +import { InfoCircleOutlined } from '@ant-design/icons'; +import { Button, Checkbox, Modal, Radio } from 'antd'; +import { useState, useImperativeHandle, forwardRef } from "react"; +type OperationKeyType = 'minimize' | 'quit' | 'maximize' | 'unmaximize'; +const QuitTips = forwardRef((props: any, ref: any) => { + useImperativeHandle(ref, () => ({ + changeModal: () => { + setIsCloseModal(true) + } + })) + const [isCloseModal, setIsCloseModal] = useState(false); + const [isTips, setIsTips] = useState(false); + const [optionsValue, setOperation] = useState('minimize'); + return ( + <> + setIsCloseModal(false)} + centered + width={'380px'} + > +
+
+ +
+ 您点击了关闭按钮,您是想: + { + setOperation(e.target.value); + }} value={optionsValue}> + 最小化到系统托盘区,不退出程序。 + 退出程序。 + +
+
+
+ { + setIsTips(e.target.checked) + storage.setItem('isTips', e.target.checked) + }} defaultChecked={isTips}>不再提示 +
+ + +
+
+
+
+ + ) +}) + +export default QuitTips \ No newline at end of file