mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 04:48:53 +00:00
15 lines
397 B
TypeScript
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));
|
|
}
|