当前位置: 首页> 娱乐> 影视 > 青岛大型网站建设_西安网站建设昆奇_建站平台哪个好_云南网络推广服务

青岛大型网站建设_西安网站建设昆奇_建站平台哪个好_云南网络推广服务

时间:2025/7/19 2:03:58来源:https://blog.csdn.net/itas109/article/details/142633003 浏览次数:0次
青岛大型网站建设_西安网站建设昆奇_建站平台哪个好_云南网络推广服务

Electron获取nodejs和chrome版本信息

环境:

electron: 30.1.1
nodejs: 20.14.0

代码

$ tree
.
+--- index.html
+--- index.js
+--- package.json

index.html

<!DOCTYPE html>
<html><head><meta charset="UTF-8" /><title>Hello Electron</title><meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline';">
</head><body><p id="version"></p><script>let info =`electron: ${process.versions.electron}, nodejs: ${process.versions.node}, chrome: ${process.versions.chrome}, v8: ${process.versions.v8}`;document.getElementById("version").innerHTML = info;console.log(info);</script>
</body></html>

index.js

const { app, BrowserWindow } = require('electron/main');
// app.commandLine.appendSwitch('remote-debugging-port', '9222');const createWindow = () => {const win = new BrowserWindow({width: 800,height: 600,webPreferences: {nodeIntegration: true,contextIsolation: false}})win.loadFile('index.html');
}app.whenReady().then(() => {createWindow();
})

package.json

{"name": "my-electron-app","version": "1.0.0","description": "","main": "index.js","scripts": {"start": "electron ."}
}

结果

electron: 30.1.1, nodejs: 20.14.0, chrome: 124.0.6367.243, v8: 12.4.254.20-electron.0

禁用 contextIsolation 和启用 nodeIntegration,会降低应用的安全性。务必谨慎使用,并确保你信任加载的所有代码和资源。

关键字:青岛大型网站建设_西安网站建设昆奇_建站平台哪个好_云南网络推广服务

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: