AIx_Smarttalk_WS/src/preload/index.js

23 lines
751 B
JavaScript

import { contextBridge } from 'electron'
import { electronAPI } from '@electron-toolkit/preload'
import TimRender from 'im_electron_sdk/dist/renderer' // im渲染部分实例
// Custom APIs for renderer
const api = {
preloadPath: __dirname, // 当前preload地址
getTimRender: () => new TimRender(), // im渲染部分实例
}
// 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
}