退出优化

This commit is contained in:
yj 2024-08-08 16:06:04 +08:00
parent 90c7ca96e0
commit 0a63a75574
7 changed files with 39 additions and 29 deletions

14
main.js
View File

@ -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)

View File

@ -27,7 +27,11 @@ window.electron = {
},
// 监听退出
onQuit: (callback) => {
ipcRenderer.on('quit', callback)
ipcRenderer.on('onQuit', callback)
},
// 退出房间
quit: () => {
return ipcRenderer.invoke('quit')
},
// 监听更新
onUpdate: (callback) => {

View File

@ -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,6 +170,7 @@ const App: React.FC = () => {
if (isState) {
setIsState(false)
window.electron.onQuit(async () => {
if (storage.getItem('isTips') === 'true') {
if (location.hash.indexOf('/meeting') !== -1) {
const data = JSON.parse(localStorage.stateInfo);
await onInvoke('levelChannel', {
@ -177,6 +178,10 @@ const App: React.FC = () => {
})
await agora.leaveChannel()
}
window.electron.quit()
} else {
quitTipsRef.current.changeModal()
}
})
}
storage.setItem('stateInfo', JSON.stringify(state))

View File

@ -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<any>()
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()
}
},
show: true,
},])
@ -102,7 +95,6 @@ const Operation: React.FC = () => {
})
}
</div>
<QuitTips ref={quitTipsRef} />
</>
)
}

View File

@ -51,7 +51,11 @@ const QuitTips = forwardRef((props: any, ref: any) => {
<div>
<Button type="primary" className='m-ant-btn' onClick={() => {
setIsCloseModal(false)
if (optionsValue === 'quit') {
window.electron.quit()
} else {
window.electron.setViewStatus(optionsValue)
}
}} size={'small'}></Button>
<Button size={'small'} type="primary" style={{ backgroundColor: '#31353A', marginLeft: '10px' }} onClick={() => setIsCloseModal(false)}></Button>
</div>

View File

@ -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 = () => {
<Popover key={rowIndex}
content={
<div className='meetingContentFooterPopover'>
<div onClick={async () => {
{user.roleId === '1' ? <div onClick={async () => {
await onInvoke('sendOper', {
roomNum: state.channelId,
type: 1,
})
leaveChannel(true)
}}></div>
}}></div> : null}
<div onClick={() => leaveChannel()}></div>
<div onClick={() => { setOpen(false) }}></div>
</div>

1
src/render.d.ts vendored
View File

@ -11,6 +11,7 @@ export interface IElectronAPI {
selectFilePath: (data?: any) => void
onFilePath: (callBack: Function) => void;
getSources: () => any;
quit: () => any;
downFile: (callBack: Function) => void;
}