当前位置: 首页 > news >正文

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

http://www.lryc.cn/news/454245.html

相关文章:

  • 【React】setState 批量更新
  • 微信小程序开发日记第二天
  • 如果您忘记了 Apple ID 和密码,按照指南可重新进入您的设备
  • Top4免费音频剪辑软件大比拼,2024年你选哪一款?
  • 基于SSM的电影院售票系统设计与实现
  • uniapp 必须掌握的细节
  • JavaWeb——Vue组件库Element(3/6):常见组件:Dialog对话框、Form表单(介绍、使用、实际效果)
  • 一个月学会Java 第2天 认识类与对象
  • 【WRF数据准备】MODIS静态地理数据下载及制备
  • MySQL数据库——索引
  • 【SpringCloud】服务注册/服务发现-Eureka
  • 让你的Github Profile高大时尚!
  • ElasticSearch备考 -- Multi match
  • 滚雪球学Oracle[2.5讲]:数据库初始化配置
  • Java - Spring框架 (ios+aop)
  • 计算机网络(十) —— IP协议详解,理解运营商和全球网络
  • 速速收藏!这些2024年上映的AI电影与短剧,申请加入你的国庆假期宅家计划!
  • 23.2 prometheus为k8s做的4大适配工作
  • 1、如何查看电脑已经连接上的wifi的密码?
  • 循环链表和双向链表
  • 【Linux庖丁解牛】—Linux基本指令(中)!
  • 【电路笔记】-运算放大器微分器
  • 【Unity踩坑】使用内购时获取Google Play license key
  • 华为OD机试真题-数组拼接-2024年OD统一考试(E卷)
  • 【Android 14源码分析】Activity启动流程-2
  • ubuntu 18.04 cuda 11.01 gpgpu-sim 裸机编译
  • 【Kubernetes】常见面试题汇总(五十二)
  • o1-preview 在 IMO 2024 第一题的实测表现
  • iOS--RunLoop原理
  • 并查集——从LeetCode题海中总结常见套路