1 Star 0 Fork 1

了了/electron demo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
preload.js 710 Bytes
一键复制 编辑 原始数据 按行查看 历史
了了 提交于 2023-12-08 00:57 . 学习demo
// preload.js
const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld(
'electron',
{
ipcRenderer: {
send: (channel, data) => {
// whitelist channels
let validChannels = ['open-page'];
if (validChannels.includes(channel)) {
ipcRenderer.send(channel, data);
}
},
on: (channel, func) => {
let validChannels = ['response'];
if (validChannels.includes(channel)) {
// strip event as it includes `sender` and is a security risk
ipcRenderer.on(channel, (event, ...args) => func(...args));
}
},
},
closeWindow: () => ipcRenderer.send('close-window')
}
);
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
NodeJS
1
https://gitee.com/idcims/electron-demo.git
git@gitee.com:idcims/electron-demo.git
idcims
electron-demo
electron demo
master

搜索帮助