Closed redmondking closed 1 year ago
Hello,
I have been using this but have been unable to access my preload commands in the app. Using window.myAPI.myfunction throws an error of undefined.
How do I resolve this? Does there need to be an additional import for it to work. See example code below.
preload.ts:
const {contextBridge, app} = require('electron') const windowAPI = { closeWindow: () => app.quit } contextBridge.exposeInMainWorld("api", windowAPI);
index.vue:
<script setup lang='ts'> const isFullscreen = ref(false) const test = () => { isFullscreen.value = !isFullscreen.value } const quitApp = window.api.closeWindow() </script>
app can only access in Main process.
app
preload.ts
ipcRenderer.send('close-window')
main.ts
ipcMain.on('close-winow', () => app.quit())
Hello,
I have been using this but have been unable to access my preload commands in the app. Using window.myAPI.myfunction throws an error of undefined.
How do I resolve this? Does there need to be an additional import for it to work. See example code below.
preload.ts:
index.vue: