Initial Commit

This commit is contained in:
Draculabo committed 2025-12-23 01:38:53 +08:00
commit d0417339c1
158 files changed
+31368

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
import { os } from '@orpc/server';
import { BrowserWindow } from 'electron';
class IPCContext {
public mainWindow: BrowserWindow | undefined;
public setMainWindow(window: BrowserWindow) {
this.mainWindow = window;
}
public get mainWindowContext() {
// Return a middleware that checks for the window at execution time, not import time
return os.middleware(({ next }) => {
if (!this.mainWindow) {
throw new Error('Main window is not set in IPC context.');
}
return next({
context: {
window: this.mainWindow,
},
});
});
}
}
export const ipcContext = new IPCContext();