feat: better ipcRenderer api expose

This commit is contained in:
Leo Wang(草鞋没号)
2024-03-11 16:06:01 +08:00
parent a9952f16c8
commit 11e9c4bffa
3 changed files with 23 additions and 13 deletions

View File

@@ -1,4 +1,4 @@
window.app.onEvent((channel, ...args) => {
console.log(channel, ...args)
window.ipcRenderer.on('main-process-message', (_event, ...args) => {
console.log('[Receive Main-process message]:', ...args)
})

6
src/vite-env.d.ts vendored
View File

@@ -7,8 +7,6 @@ declare module '*.vue' {
}
interface Window {
app: {
// Expose in the `electron/preload/index.ts`
onEvent: (cb: (channel: string, ...args: any[]) => void) => void
}
// expose in the `electron/preload/index.ts`
ipcRenderer: import('electron').IpcRenderer
}