mirror of
https://github.com/electron-vite/electron-vite-vue
synced 2025-01-19 20:07:06 +08:00
chore(docs): Communication
This commit is contained in:
parent
14a548753b
commit
fcb836a492
23
README.md
23
README.md
@ -37,6 +37,29 @@
|
|||||||
## Communication
|
## Communication
|
||||||
- All NodeJs、Electron API invoke passed `Preload script`
|
- 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
|
## Branchs
|
||||||
- [ant-design-vue](https://github.com/caoxiemeihao/electron-vue-vite/tree/ant-design-vue)
|
- [ant-design-vue](https://github.com/caoxiemeihao/electron-vue-vite/tree/ant-design-vue)
|
||||||
* [x] Use tsx
|
* [x] Use tsx
|
||||||
|
Loading…
x
Reference in New Issue
Block a user