AIx_Smarttalk/src/preload/index.js

22 lines
611 B
JavaScript
Raw Normal View History

2024-07-23 17:20:36 +08:00
import { contextBridge, ipcRenderer } from 'electron'
2024-07-08 16:24:56 +08:00
import { electronAPI } from '@electron-toolkit/preload'
// Custom APIs for renderer
const api = {}
// Use `contextBridge` APIs to expose Electron APIs to
// renderer only if context isolation is enabled, otherwise
// just add to the DOM global.
if (process.contextIsolated) {
try {
contextBridge.exposeInMainWorld('electron', electronAPI)
2024-07-23 17:20:36 +08:00
contextBridge.exposeInMainWorld('electronAPI')
2024-07-08 16:24:56 +08:00
contextBridge.exposeInMainWorld('api', api)
} catch (error) {
console.error(error)
}
} else {
window.electron = electronAPI
window.api = api
}