mirror of
https://github.com/electron-vite/electron-vite-vue
synced 2025-03-03 23:40:09 +08:00
communication declare
This commit is contained in:
parent
a9ad136d11
commit
aeb1b6f4e3
@ -1,8 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Renderer and Main bridge
|
* Renderer and Main bridge
|
||||||
* @refresh https://newbedev.com/how-to-use-preload-js-properly-in-electron
|
|
||||||
*/
|
*/
|
||||||
import { contextBridge, ipcRenderer } from 'electron'
|
import fs from 'fs'
|
||||||
|
import { contextBridge, ipcRenderer } from 'electron'
|
||||||
|
|
||||||
contextBridge.exposeInMainWorld('ipcRenderer', ipcRenderer)
|
contextBridge.exposeInMainWorld('fs', fs)
|
||||||
|
|
||||||
|
contextBridge.exposeInMainWorld('ipcRenderer', ipcRenderer)
|
||||||
|
@ -3,5 +3,8 @@ import App from './App.vue'
|
|||||||
import './index.css'
|
import './index.css'
|
||||||
|
|
||||||
createApp(App)
|
createApp(App)
|
||||||
.mount('#app')
|
.mount('#app')
|
||||||
.$nextTick(window.removeLoading)
|
.$nextTick(window.removeLoading)
|
||||||
|
|
||||||
|
console.log('fs', window.fs)
|
||||||
|
console.log('ipcRenderer', window.ipcRenderer)
|
||||||
|
4
typings/global.d.ts
vendored
4
typings/global.d.ts
vendored
@ -9,4 +9,8 @@ declare namespace NodeJS {
|
|||||||
interface Window {
|
interface Window {
|
||||||
/** 关闭预加载动画 */
|
/** 关闭预加载动画 */
|
||||||
removeLoading: () => void
|
removeLoading: () => void
|
||||||
|
/** NodeJs fs */
|
||||||
|
fs: typeof import('fs')
|
||||||
|
/** Electron ipcRenderer */
|
||||||
|
ipcRenderer: import('electron').IpcRenderer
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user