Files
贾同学 4768ef2d26 init
2025-10-16 20:01:57 +08:00

16 lines
473 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* 如果启用了上下文隔离渲染进程无法使用electron的api
* 可通过contextBridge 导出api给渲染进程使用
*/
import { type IpcRenderer, contextBridge, ipcRenderer } from 'electron';
// 确保contextBridge.exposeInMainWorld的参数类型正确这里进行简单的类型定义示例
type ElectronApi = {
ipcRenderer: IpcRenderer;
};
const ele: ElectronApi = {
ipcRenderer,
};
contextBridge.exposeInMainWorld('electron', ele);