mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-01 18:33:33 +00:00
Add listeners and preload for log/toast from main
This commit is contained in:
parent
69f82a9427
commit
b69290f9f2
3 changed files with 55 additions and 1 deletions
|
|
@ -1,10 +1,13 @@
|
|||
import { useMemo } from 'react';
|
||||
import { useMemo, useEffect } from 'react';
|
||||
import isElectron from 'is-electron';
|
||||
import { Navigate, Outlet } from 'react-router-dom';
|
||||
import { AppRoute } from '/@/renderer/router/routes';
|
||||
import { useCurrentServer } from '/@/renderer/store';
|
||||
import { toast } from '/@/renderer/components';
|
||||
|
||||
const localSettings = isElectron() ? window.electron.localSettings : null;
|
||||
const ipc = isElectron() ? window.electron.ipc : null;
|
||||
const utils = isElectron() ? window.electron.utils : null;
|
||||
|
||||
export const AppOutlet = () => {
|
||||
const currentServer = useCurrentServer();
|
||||
|
|
@ -29,6 +32,16 @@ export const AppOutlet = () => {
|
|||
return isActionRequired;
|
||||
}, [currentServer]);
|
||||
|
||||
useEffect(() => {
|
||||
utils?.mainMessageListener((_event, data) => {
|
||||
toast.show(data);
|
||||
});
|
||||
|
||||
return () => {
|
||||
ipc?.removeAllListeners('toast-from-main');
|
||||
};
|
||||
}, []);
|
||||
|
||||
if (isActionsRequired) {
|
||||
return (
|
||||
<Navigate
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue