Electron获取nodejs和chrome版本信息

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,会降低应用的安全性。务必谨慎使用,并确保你信任加载的所有代码和资源。

相关推荐
打瞌睡的朱尤16 小时前
Vue day10 完整购物网页(登录页,首页,搜索)
前端·javascript·vue.js
扶苏100217 小时前
深入理解 Vue 3 的 watchEffect
前端·javascript·vue.js
yanlele19 小时前
AI Coding 时代下, 关于你会写代码这件事儿, 还重要吗?
前端·javascript·ai编程
打瞌睡的朱尤20 小时前
Vue day9 购物车,项目,vant组件库,vw,路由
前端·javascript·vue.js
xinhuanjieyi1 天前
python获取股票分红
chrome·python·elasticsearch
cc.ChenLy1 天前
【CSS进阶】毛玻璃效果与代码解析
前端·javascript·css
西门吹-禅1 天前
node js 性能处理
开发语言·javascript·ecmascript
一只大侠的侠1 天前
React Native for OpenHarmony:日期范围选择器实现
javascript·react native·react.js
EstherNi1 天前
仿照elementui写图片放大的案例,但多加了下载按钮,vue3
javascript·vue.js·elementui
一只大侠的侠1 天前
React Native for OpenHarmony:DatePicker 日期选择器组件详解
javascript·react native·react.js