It's hard to keep coding consistently, especially since I've been working overtime until 10p.m. lately.
(I know it's not great to make excuses, but I'm determined to push through.)
By the way, I added a **contextBridge**
(by including a **preload.js**
file) to the previous program.
However, it doesn't work and I have been trying to solve this issue.
What I did
- Added a secure process
// index.js
const button = document.getElementById("button");
const receive = document.getElementById("receive");
const send = document.getElementById("send");
button.addEventListener('click', async () => {
receive.textContent = await window.myAPI.buttonEvent(send.value);// Changed
});
// preload.js
const {ipcRenderer, contextBridge} = require('electron');
contextBridge.exposeInMainWorld('myAPI',{
buttonEvent: (text) => ipcRenderer.invoke('two-way-com', text),
});
I'll continue working on solving this problem.
Top comments (0)