Files
AFFiNE-Mirror/apps/electron/layers/main/src/send-main-event.ts
2023-04-24 12:53:21 -05:00

15 lines
397 B
TypeScript

import { BrowserWindow } from 'electron';
import type { MainEventMap } from '../../main-events';
function getActiveWindows() {
return BrowserWindow.getAllWindows().filter(win => !win.isDestroyed());
}
export function sendMainEvent<T extends keyof MainEventMap>(
type: T,
...args: Parameters<MainEventMap[T]>
) {
getActiveWindows().forEach(win => win.webContents.send(type, ...args));
}