AIx_Smarttalk/src/preload/index.js

23 lines
751 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'
2024-08-19 14:21:42 +08:00
import TimRender from 'im_electron_sdk/dist/renderer' // im渲染部分实例
2024-07-08 16:24:56 +08:00
// Custom APIs for renderer
2024-07-25 13:24:31 +08:00
const api = {
2024-08-14 16:31:08 +08:00
preloadPath: __dirname, // 当前preload地址
2024-08-19 14:21:42 +08:00
getTimRender: () => new TimRender(), // im渲染部分实例
2024-07-25 13:24:31 +08:00
}
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
}