<!--index.html--><!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><title>Hello World!</title></head><body><h1>Hello World!</h1>
We are using Node.js <spanid="node-version"></span>,
Chromium <spanid="chrome-version"></span>,
and Electron <spanid="electron-version"></span>.
</body></html>
创建 prelode.js
// preload.js// 所有的 Node.js API接口 都可以在 preload 进程中被调用。它拥有与Chrome扩展一样的沙盒。
window.addEventListener('DOMContentLoaded',()=>{constreplaceText=(selector, text)=>{const element = document.getElementById(selector)if(element) element.innerText = text
}for(const dependency of['chrome','node','electron']){replaceText(`${dependency}-version`, process.versions[dependency])}})