add tray and add settings
This commit is contained in:
27
src/renderer/utils/TrayBridge.tsx
Normal file
27
src/renderer/utils/TrayBridge.tsx
Normal file
@ -0,0 +1,27 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
export function TrayBridge() {
|
||||
const navigate = useNavigate();
|
||||
|
||||
useEffect(() => {
|
||||
const onNavigate = (to: unknown) => {
|
||||
navigate(String(to));
|
||||
};
|
||||
|
||||
const onLogout = () => {
|
||||
localStorage.removeItem('launcher_config');
|
||||
navigate('/login');
|
||||
};
|
||||
|
||||
window.electron.ipcRenderer.on('tray-navigate', onNavigate);
|
||||
window.electron.ipcRenderer.on('tray-logout', onLogout);
|
||||
|
||||
return () => {
|
||||
window.electron.ipcRenderer.removeAllListeners('tray-navigate');
|
||||
window.electron.ipcRenderer.removeAllListeners('tray-logout');
|
||||
};
|
||||
}, [navigate]);
|
||||
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user