1 Star 0 Fork 22

java客栈的小二/godoDb

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
preload.js 1.12 KB
一键复制 编辑 原始数据 按行查看 历史
godo 提交于 2023-08-21 03:27 . add pre
// All of the Node.js APIs are available in the preload process.
// It has the same sandbox as a Chrome extension.
window.addEventListener('DOMContentLoaded', () => {
const replaceText = (selector, text) => {
const element = document.getElementById(selector)
if (element) element.innerText = text
}
for (const type of ['chrome', 'node', 'electron']) {
replaceText(`${type}-version`, process.versions[type])
}
})
// Preload (Isolated World)
// 三种方式在main与html之间通信
const { contextBridge, ipcRenderer } = require('electron')
contextBridge.exposeInMainWorld(
'ipcRenderer',
{
// From render to main.
send: (channel, args) => { return ipcRenderer.sendSync(channel, 'ping') },
// From main to render.
// listener为自定义的消息处理函数,原型在renderer中
receive: (channel, listener) => {
ipcRenderer.on(channel, (event, args) => listener(args));
},
// From render to main and back again.
invoke: (channel, args) => {
return ipcRenderer.invoke(channel, args);
}
}
)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
NodeJS
1
https://gitee.com/w160/gododb.git
[email protected]:w160/gododb.git
w160
gododb
godoDb
master

搜索帮助