chore(docs): Communication

This commit is contained in:
草鞋没号 2021-11-02 15:23:29 +08:00
parent 14a548753b
commit fcb836a492

View File

@ -37,6 +37,29 @@
## Communication
- All NodeJs、Electron API invoke passed `Preload script`
* **src/preload/index.ts**
```typescript
// --------- Expose some API to Renderer process. ---------
contextBridge.exposeInMainWorld('fs', fs)
contextBridge.exposeInMainWorld('ipcRenderer', ipcRenderer)
```
* **typings/global.d.ts**
```typescript
interface Window {
fs: typeof import('fs')
ipcRenderer: import('electron').IpcRenderer
}
```
* **src/render/main.ts**
```typescript
console.log('fs', window.fs)
console.log('ipcRenderer', window.ipcRenderer)
```
## Branchs
- [ant-design-vue](https://github.com/caoxiemeihao/electron-vue-vite/tree/ant-design-vue)
* [x] Use tsx