退出优化
This commit is contained in:
parent
90c7ca96e0
commit
0a63a75574
14
main.js
14
main.js
|
|
@ -65,7 +65,9 @@ function showWindow() {
|
||||||
createWindow();
|
createWindow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function quit() {
|
||||||
|
app.quit()
|
||||||
|
}
|
||||||
function createTray() {
|
function createTray() {
|
||||||
const iconPath = `${__dirname}/src/assets/icon.png`;
|
const iconPath = `${__dirname}/src/assets/icon.png`;
|
||||||
const trayIcon = nativeImage.createFromPath(iconPath);
|
const trayIcon = nativeImage.createFromPath(iconPath);
|
||||||
|
|
@ -79,8 +81,7 @@ function createTray() {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '退出', click: async () => {
|
label: '退出', click: async () => {
|
||||||
await mainWindow.webContents.send('quit');
|
await mainWindow.webContents.send('onQuit');
|
||||||
app.quit();
|
|
||||||
},
|
},
|
||||||
// icon: iconPath,
|
// icon: iconPath,
|
||||||
},
|
},
|
||||||
|
|
@ -160,8 +161,7 @@ app.on('ready', () => {
|
||||||
ipcMain.handle('setViewStatus', async (event, status) => {
|
ipcMain.handle('setViewStatus', async (event, status) => {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 'quit':
|
case 'quit':
|
||||||
await mainWindow.webContents.send('quit');
|
await mainWindow.webContents.send('onQuit');
|
||||||
app.quit();
|
|
||||||
break;
|
break;
|
||||||
case 'maximize':
|
case 'maximize':
|
||||||
mainWindow.maximize()
|
mainWindow.maximize()
|
||||||
|
|
@ -190,6 +190,10 @@ app.on('ready', () => {
|
||||||
ipcMain.handle('setWriteText', (event, text) => {
|
ipcMain.handle('setWriteText', (event, text) => {
|
||||||
clipboard.writeText(text)
|
clipboard.writeText(text)
|
||||||
});
|
});
|
||||||
|
// 退出
|
||||||
|
ipcMain.handle('quit', (event) => {
|
||||||
|
quit()
|
||||||
|
});
|
||||||
// 加入房间通知
|
// 加入房间通知
|
||||||
ipcMain.handle('joinNotification', (event, user) => {
|
ipcMain.handle('joinNotification', (event, user) => {
|
||||||
createNotification(user)
|
createNotification(user)
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,11 @@ window.electron = {
|
||||||
},
|
},
|
||||||
// 监听退出
|
// 监听退出
|
||||||
onQuit: (callback) => {
|
onQuit: (callback) => {
|
||||||
ipcRenderer.on('quit', callback)
|
ipcRenderer.on('onQuit', callback)
|
||||||
|
},
|
||||||
|
// 退出房间
|
||||||
|
quit: () => {
|
||||||
|
return ipcRenderer.invoke('quit')
|
||||||
},
|
},
|
||||||
// 监听更新
|
// 监听更新
|
||||||
onUpdate: (callback) => {
|
onUpdate: (callback) => {
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@ const App: React.FC = () => {
|
||||||
storage.setItem('reconnect', true)
|
storage.setItem('reconnect', true)
|
||||||
})
|
})
|
||||||
window.electron.onUpdate((_e: any, data: any) => {
|
window.electron.onUpdate((_e: any, data: any) => {
|
||||||
if (location.hash.indexOf('/meeting') !== -1) {
|
if (location.hash.indexOf('/meeting') === -1) {
|
||||||
updateModalRef.current.changeModal(data)
|
updateModalRef.current.changeModal(data)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -170,6 +170,7 @@ const App: React.FC = () => {
|
||||||
if (isState) {
|
if (isState) {
|
||||||
setIsState(false)
|
setIsState(false)
|
||||||
window.electron.onQuit(async () => {
|
window.electron.onQuit(async () => {
|
||||||
|
if (storage.getItem('isTips') === 'true') {
|
||||||
if (location.hash.indexOf('/meeting') !== -1) {
|
if (location.hash.indexOf('/meeting') !== -1) {
|
||||||
const data = JSON.parse(localStorage.stateInfo);
|
const data = JSON.parse(localStorage.stateInfo);
|
||||||
await onInvoke('levelChannel', {
|
await onInvoke('levelChannel', {
|
||||||
|
|
@ -177,6 +178,10 @@ const App: React.FC = () => {
|
||||||
})
|
})
|
||||||
await agora.leaveChannel()
|
await agora.leaveChannel()
|
||||||
}
|
}
|
||||||
|
window.electron.quit()
|
||||||
|
} else {
|
||||||
|
quitTipsRef.current.changeModal()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
storage.setItem('stateInfo', JSON.stringify(state))
|
storage.setItem('stateInfo', JSON.stringify(state))
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
import styles from '@/components/Operation/index.module.scss'
|
import styles from '@/components/Operation/index.module.scss'
|
||||||
import { storage } from '@/utils';
|
|
||||||
import ImageUrl from '@/utils/package/ImageUrl';
|
import ImageUrl from '@/utils/package/ImageUrl';
|
||||||
import { useEffect, useState, useRef } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import QuitTips from '../QuitTips';
|
|
||||||
type OperationKeyType = 'minimize' | 'quit' | 'maximize' | 'unmaximize';
|
type OperationKeyType = 'minimize' | 'quit' | 'maximize' | 'unmaximize';
|
||||||
type OperationType = {
|
type OperationType = {
|
||||||
icon: string;
|
icon: string;
|
||||||
|
|
@ -12,7 +10,6 @@ type OperationType = {
|
||||||
show: boolean;
|
show: boolean;
|
||||||
}
|
}
|
||||||
const Operation: React.FC = () => {
|
const Operation: React.FC = () => {
|
||||||
const quitTipsRef = useRef<any>()
|
|
||||||
const [_windowSize, setWindowSize] = useState({
|
const [_windowSize, setWindowSize] = useState({
|
||||||
width: window.innerWidth,
|
width: window.innerWidth,
|
||||||
height: window.innerHeight,
|
height: window.innerHeight,
|
||||||
|
|
@ -49,11 +46,7 @@ const Operation: React.FC = () => {
|
||||||
key: 'quit',
|
key: 'quit',
|
||||||
title: '关闭',
|
title: '关闭',
|
||||||
onClick: (key: OperationKeyType) => {
|
onClick: (key: OperationKeyType) => {
|
||||||
if (storage.getItem('isTips') === 'true') {
|
|
||||||
window.electron.setViewStatus(key)
|
window.electron.setViewStatus(key)
|
||||||
} else {
|
|
||||||
quitTipsRef.current.changeModal()
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
show: true,
|
show: true,
|
||||||
},])
|
},])
|
||||||
|
|
@ -102,7 +95,6 @@ const Operation: React.FC = () => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<QuitTips ref={quitTipsRef} />
|
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,11 @@ const QuitTips = forwardRef((props: any, ref: any) => {
|
||||||
<div>
|
<div>
|
||||||
<Button type="primary" className='m-ant-btn' onClick={() => {
|
<Button type="primary" className='m-ant-btn' onClick={() => {
|
||||||
setIsCloseModal(false)
|
setIsCloseModal(false)
|
||||||
|
if (optionsValue === 'quit') {
|
||||||
|
window.electron.quit()
|
||||||
|
} else {
|
||||||
window.electron.setViewStatus(optionsValue)
|
window.electron.setViewStatus(optionsValue)
|
||||||
|
}
|
||||||
}} size={'small'}>确定</Button>
|
}} size={'small'}>确定</Button>
|
||||||
<Button size={'small'} type="primary" style={{ backgroundColor: '#31353A', marginLeft: '10px' }} onClick={() => setIsCloseModal(false)}>取消</Button>
|
<Button size={'small'} type="primary" style={{ backgroundColor: '#31353A', marginLeft: '10px' }} onClick={() => setIsCloseModal(false)}>取消</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -670,9 +670,9 @@ const Meeting: React.FC = () => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// 演讲者模式
|
// 演讲者模式
|
||||||
const changeSpeakerMode = (): void => {
|
// const changeSpeakerMode = (): void => {
|
||||||
speakerModeModalRef.current.changeSpeakerMode()
|
// speakerModeModalRef.current.changeSpeakerMode()
|
||||||
}
|
// }
|
||||||
// 获取当前模式样式
|
// 获取当前模式样式
|
||||||
const getMeetingContentBodyLeftModeClass = (): string => {
|
const getMeetingContentBodyLeftModeClass = (): string => {
|
||||||
switch (meetingMode) {
|
switch (meetingMode) {
|
||||||
|
|
@ -991,13 +991,13 @@ const Meeting: React.FC = () => {
|
||||||
<Popover key={rowIndex}
|
<Popover key={rowIndex}
|
||||||
content={
|
content={
|
||||||
<div className='meetingContentFooterPopover'>
|
<div className='meetingContentFooterPopover'>
|
||||||
<div onClick={async () => {
|
{user.roleId === '1' ? <div onClick={async () => {
|
||||||
await onInvoke('sendOper', {
|
await onInvoke('sendOper', {
|
||||||
roomNum: state.channelId,
|
roomNum: state.channelId,
|
||||||
type: 1,
|
type: 1,
|
||||||
})
|
})
|
||||||
leaveChannel(true)
|
leaveChannel(true)
|
||||||
}}>全员结束会议</div>
|
}}>全员结束会议</div> : null}
|
||||||
<div onClick={() => leaveChannel()}>仅自己离开</div>
|
<div onClick={() => leaveChannel()}>仅自己离开</div>
|
||||||
<div onClick={() => { setOpen(false) }}>取消</div>
|
<div onClick={() => { setOpen(false) }}>取消</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ export interface IElectronAPI {
|
||||||
selectFilePath: (data?: any) => void
|
selectFilePath: (data?: any) => void
|
||||||
onFilePath: (callBack: Function) => void;
|
onFilePath: (callBack: Function) => void;
|
||||||
getSources: () => any;
|
getSources: () => any;
|
||||||
|
quit: () => any;
|
||||||
downFile: (callBack: Function) => void;
|
downFile: (callBack: Function) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue