加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
renderer.js 1.75 KB
一键复制 编辑 原始数据 按行查看 历史
zaojian.dzj 提交于 2022-11-14 09:27 . Web Workers 测试代码
/**
* This file is loaded via the <script> tag in the index.html file and will
* be executed in the renderer process for that window. No Node.js APIs are
* available in this process because `nodeIntegration` is turned off and
* `contextIsolation` is turned on. Use the contextBridge API in `preload.js`
* to expose Node.js functionality from the main process.
*/
const ipcRenderer = require('electron').ipcRenderer;
ipcRenderer.on('cs-ready', (e, msg) => {
console.log("ChildProcess isOpen: " + msg);
// alert("ChildProcess isOpen: " + msg)
document.getElementById('recivemsg').value = msg
})
document.getElementById("open").addEventListener("click",() =>{
console.log("open");
ChildProcess(true)
});
document.getElementById("close").addEventListener("click", () => {
console.log("open");
ChildProcess(false)
});
document.getElementById("open").onclick = () => {
console.log("open");
ChildProcess(true)
};
function ChildProcess(isOpen) {
//发消息,有html的按钮调用,给主进程发消息,回调中关闭进程
console.log("ChildProcess isOpen: " + isOpen);
// alert("ChildProcess isOpen: " + isOpen)
var appname = "";
if (isOpen) {
appname = document.getElementById('txt_exe').value;
ipcRenderer.send('open-child-now', appname)
console.log("open-called-now");
} else {
ipcRenderer.send('kill-child-now', appname)
console.log("close");
}
}
const btn = document.getElementById('btn')
const filePathElement = document.getElementById('filePath')
btn.addEventListener('click', async () => {
console.log("打开");
console.log(123);
alert('dianji')
const filePath = await window.electronAPI.openFile()
filePathElement.innerText = filePath
})
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化