diff --git a/README.md b/README.md index 26969a7..1195587 100644 --- a/README.md +++ b/README.md @@ -70,9 +70,20 @@ Once `dev` or `build` npm-script executed will be generate named `dist` folder. contextBridge.exposeInMainWorld('ipcRenderer', ipcRenderer) ``` +* **src/renderer/src/global.d.ts** + + ```typescript + // Defined on the window + interface Window { + fs: typeof import('fs') + ipcRenderer: import('electron').IpcRenderer + } + ``` + * **src/renderer/src/main.ts** ```typescript + // Use Electron, NodeJs API in Renderer-process console.log('fs', window.fs) console.log('ipcRenderer', window.ipcRenderer) ``` diff --git a/README.zh-CN.md b/README.zh-CN.md index e7adf61..552f101 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -71,9 +71,20 @@ contextBridge.exposeInMainWorld('ipcRenderer', ipcRenderer) ``` +* **src/renderer/src/global.d.ts** + + ```typescript + // Defined on the window + interface Window { + fs: typeof import('fs') + ipcRenderer: import('electron').IpcRenderer + } + ``` + * **src/renderer/main.ts** ```typescript + // Use Electron, NodeJs API in Renderer-process console.log('fs', window.fs) console.log('ipcRenderer', window.ipcRenderer) ```