Files
pqs-9100_client/frontend/src/utils/ipcRenderer.js

40 lines
1.3 KiB
JavaScript
Raw Normal View History

2025-10-14 19:00:47 +08:00
declare global {
interface Window {
electron?: any;
}
}
const Renderer = (window.require && window.require('electron')) || window.electron || {};
2024-08-07 21:48:57 +08:00
/**
* ipc
* 官方api说明https://www.electronjs.org/zh/docs/latest/api/ipc-renderer
*
2024-08-07 21:48:57 +08:00
* 属性/方法
* ipc.invoke(channel, param) - 发送异步消息invoke/handle 模型
* ipc.sendSync(channel, param) - 发送同步消息send/on 模型
* ipc.on(channel, listener) - 监听 channel, 当新消息到达调用 listener
* ipc.once(channel, listener) - 添加一次性 listener 函数
* ipc.removeListener(channel, listener) - 为特定的 channel 从监听队列中删除特定的 listener 监听者
* ipc.removeAllListeners(channel) - 移除所有的监听器当指定 channel 时只移除与其相关的所有监听器
* ipc.send(channel, ...args) - 通过channel向主进程发送异步消息
* ipc.postMessage(channel, message, [transfer]) - 发送消息到主进程
* ipc.sendTo(webContentsId, channel, ...args) - 通过 channel 发送消息到带有 webContentsId 的窗口
* ipc.sendToHost(channel, ...args) - 消息会被发送到 host 页面上的 <webview> 元素
*/
/**
* ipc
*/
2025-10-14 19:00:47 +08:00
const ipc = Renderer.ipcRenderer || undefined;
2024-08-07 21:48:57 +08:00
/**
* 是否为EE环境
*/
2025-10-14 19:00:47 +08:00
const isEE = ipc ? true : false;
export {
Renderer, ipc, isEE
};
2024-08-07 21:48:57 +08:00