From b6927955fafba04cc6a7d2d2a8c4ee4dc9c2eead Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8D=89=E9=9E=8B=E6=B2=A1=E5=8F=B7?= <308487730@qq.com> Date: Thu, 6 Jan 2022 09:21:29 +0800 Subject: [PATCH] chore(docs): update --- README.md | 11 +++++++++++ README.zh-CN.md | 11 +++++++++++ 2 files changed, 22 insertions(+) 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) ```