mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-10 09:53:48 +00:00
ipc react-electron
This commit is contained in:
@@ -7,6 +7,7 @@ import MinIconBtn from './buttons/MinIconBtn';
|
||||
import QuitIconBtn from './buttons/QuitIconBtn';
|
||||
import style from './MenuBar.module.css';
|
||||
import HelpIconBtn from './buttons/HelpIconBtn';
|
||||
const { ipcRenderer } = window.require('electron');
|
||||
|
||||
export default function MenuBar(props) {
|
||||
const { onOpen, onClose } = props;
|
||||
@@ -15,13 +16,32 @@ export default function MenuBar(props) {
|
||||
downloadEvents();
|
||||
};
|
||||
|
||||
const handleIPC = (action) => {
|
||||
switch (action) {
|
||||
case 'min':
|
||||
ipcRenderer.send('set-window', 'to-tray');
|
||||
break;
|
||||
case 'max':
|
||||
ipcRenderer.send('set-window', 'to-max');
|
||||
break;
|
||||
case 'shutdown':
|
||||
ipcRenderer.send('shutdown', 'now');
|
||||
break;
|
||||
case 'help':
|
||||
ipcRenderer.send('send-to-link', 'help');
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<QuitIconBtn size='md' />
|
||||
<MaxIconBtn size='md' />
|
||||
<MinIconBtn size='md' />
|
||||
<QuitIconBtn size='md' clickhandler={() => handleIPC('shutdown')} />
|
||||
<MaxIconBtn size='md' clickhandler={() => handleIPC('max')} />
|
||||
<MinIconBtn size='md' clickhandler={() => handleIPC('min')} />
|
||||
<div className={style.gap} />
|
||||
<HelpIconBtn size='md' disabled />
|
||||
<HelpIconBtn size='md' clickhandler={() => handleIPC('help')} />
|
||||
<SettingsIconBtn size='md' disabled />
|
||||
<InfoIconBtn size='md' clickhandler={onOpen} />
|
||||
<DownloadIconBtn size='md' clickhandler={handleDownload} />
|
||||
|
||||
Reference in New Issue
Block a user