electron-game-quickstart/electron/preload.ts

8 lines
380 B
TypeScript
Raw Normal View History

2024-03-13 14:26:41 +00:00
import { contextBridge, ipcRenderer } from 'electron';
contextBridge.exposeInMainWorld('electronAPI', {
writeFile: (filePath: string, content: string) => ipcRenderer.invoke('write-file', filePath, content),
readFile: (filePath: string) => ipcRenderer.invoke('read-file', filePath),
listFiles: (dirPath: string) => ipcRenderer.invoke('list-files', dirPath)
});