From 0a63a755743ad31b1d0de7b0b5f932ae09b26652 Mon Sep 17 00:00:00 2001 From: yj <1336058017@qq.com> Date: Thu, 8 Aug 2024 16:06:04 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=80=E5=87=BA=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.js | 14 +++++++++----- preload.js | 6 +++++- src/App.tsx | 19 ++++++++++++------- src/components/Operation/index.tsx | 12 ++---------- src/components/QuitTips/index.tsx | 6 +++++- src/page/Meeting/index.tsx | 10 +++++----- src/render.d.ts | 1 + 7 files changed, 39 insertions(+), 29 deletions(-) diff --git a/main.js b/main.js index b248fda..0055d82 100644 --- a/main.js +++ b/main.js @@ -65,7 +65,9 @@ function showWindow() { createWindow(); } } - +function quit() { + app.quit() +} function createTray() { const iconPath = `${__dirname}/src/assets/icon.png`; const trayIcon = nativeImage.createFromPath(iconPath); @@ -79,8 +81,7 @@ function createTray() { }, { label: '退出', click: async () => { - await mainWindow.webContents.send('quit'); - app.quit(); + await mainWindow.webContents.send('onQuit'); }, // icon: iconPath, }, @@ -160,8 +161,7 @@ app.on('ready', () => { ipcMain.handle('setViewStatus', async (event, status) => { switch (status) { case 'quit': - await mainWindow.webContents.send('quit'); - app.quit(); + await mainWindow.webContents.send('onQuit'); break; case 'maximize': mainWindow.maximize() @@ -190,6 +190,10 @@ app.on('ready', () => { ipcMain.handle('setWriteText', (event, text) => { clipboard.writeText(text) }); + // 退出 + ipcMain.handle('quit', (event) => { + quit() + }); // 加入房间通知 ipcMain.handle('joinNotification', (event, user) => { createNotification(user) diff --git a/preload.js b/preload.js index a5e9a40..9a6fe1f 100644 --- a/preload.js +++ b/preload.js @@ -27,7 +27,11 @@ window.electron = { }, // 监听退出 onQuit: (callback) => { - ipcRenderer.on('quit', callback) + ipcRenderer.on('onQuit', callback) + }, + // 退出房间 + quit: () => { + return ipcRenderer.invoke('quit') }, // 监听更新 onUpdate: (callback) => { diff --git a/src/App.tsx b/src/App.tsx index 528a2c6..669dc26 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -148,7 +148,7 @@ const App: React.FC = () => { storage.setItem('reconnect', true) }) window.electron.onUpdate((_e: any, data: any) => { - if (location.hash.indexOf('/meeting') !== -1) { + if (location.hash.indexOf('/meeting') === -1) { updateModalRef.current.changeModal(data) } }) @@ -170,12 +170,17 @@ const App: React.FC = () => { if (isState) { setIsState(false) window.electron.onQuit(async () => { - if (location.hash.indexOf('/meeting') !== -1) { - const data = JSON.parse(localStorage.stateInfo); - await onInvoke('levelChannel', { - roomNum: data.channelId - }) - await agora.leaveChannel() + if (storage.getItem('isTips') === 'true') { + if (location.hash.indexOf('/meeting') !== -1) { + const data = JSON.parse(localStorage.stateInfo); + await onInvoke('levelChannel', { + roomNum: data.channelId + }) + await agora.leaveChannel() + } + window.electron.quit() + } else { + quitTipsRef.current.changeModal() } }) } diff --git a/src/components/Operation/index.tsx b/src/components/Operation/index.tsx index 7bc5477..3ccf8a3 100644 --- a/src/components/Operation/index.tsx +++ b/src/components/Operation/index.tsx @@ -1,8 +1,6 @@ import styles from '@/components/Operation/index.module.scss' -import { storage } from '@/utils'; import ImageUrl from '@/utils/package/ImageUrl'; -import { useEffect, useState, useRef } from "react"; -import QuitTips from '../QuitTips'; +import { useEffect, useState } from "react"; type OperationKeyType = 'minimize' | 'quit' | 'maximize' | 'unmaximize'; type OperationType = { icon: string; @@ -12,7 +10,6 @@ type OperationType = { show: boolean; } const Operation: React.FC = () => { - const quitTipsRef = useRef() const [_windowSize, setWindowSize] = useState({ width: window.innerWidth, height: window.innerHeight, @@ -49,11 +46,7 @@ const Operation: React.FC = () => { key: 'quit', title: '关闭', onClick: (key: OperationKeyType) => { - if (storage.getItem('isTips') === 'true') { - window.electron.setViewStatus(key) - } else { - quitTipsRef.current.changeModal() - } + window.electron.setViewStatus(key) }, show: true, },]) @@ -102,7 +95,6 @@ const Operation: React.FC = () => { }) } - ) } diff --git a/src/components/QuitTips/index.tsx b/src/components/QuitTips/index.tsx index d823f8e..52cea03 100644 --- a/src/components/QuitTips/index.tsx +++ b/src/components/QuitTips/index.tsx @@ -51,7 +51,11 @@ const QuitTips = forwardRef((props: any, ref: any) => {
diff --git a/src/page/Meeting/index.tsx b/src/page/Meeting/index.tsx index 07c0cc4..4c67739 100644 --- a/src/page/Meeting/index.tsx +++ b/src/page/Meeting/index.tsx @@ -670,9 +670,9 @@ const Meeting: React.FC = () => { }) } // 演讲者模式 - const changeSpeakerMode = (): void => { - speakerModeModalRef.current.changeSpeakerMode() - } + // const changeSpeakerMode = (): void => { + // speakerModeModalRef.current.changeSpeakerMode() + // } // 获取当前模式样式 const getMeetingContentBodyLeftModeClass = (): string => { switch (meetingMode) { @@ -991,13 +991,13 @@ const Meeting: React.FC = () => { -
{ + {user.roleId === '1' ?
{ await onInvoke('sendOper', { roomNum: state.channelId, type: 1, }) leaveChannel(true) - }}>全员结束会议
+ }}>全员结束会议
: null}
leaveChannel()}>仅自己离开
{ setOpen(false) }}>取消
diff --git a/src/render.d.ts b/src/render.d.ts index 11605b3..d37abc9 100644 --- a/src/render.d.ts +++ b/src/render.d.ts @@ -11,6 +11,7 @@ export interface IElectronAPI { selectFilePath: (data?: any) => void onFilePath: (callBack: Function) => void; getSources: () => any; + quit: () => any; downFile: (callBack: Function) => void; }