AIx_Smarttalk/src/preload/index.js

21 lines
547 B
JavaScript
Raw Normal View History

2024-07-25 13:24:31 +08:00
import { contextBridge } from 'electron'
2024-07-08 16:24:56 +08:00
import { electronAPI } from '@electron-toolkit/preload'
// Custom APIs for renderer
2024-07-25 13:24:31 +08:00
const api = {
}
2024-07-08 16:24:56 +08:00
// 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)
contextBridge.exposeInMainWorld('api', api)
} catch (error) {
console.error(error)
}
} else {
window.electron = electronAPI
window.api = api
}