Skip to main content

Electron 20.0.0

· 8 min read

Electron 20.0.0 已发布!它包含对 Chromium 104、V8 10.4 和 Node.js 16.15.0 的升级。请阅读下文了解更多详情!

¥Electron 20.0.0 has been released! It includes upgrades to Chromium 104, V8 10.4, and Node.js 16.15.0. Read below for more details!


Electron 团队非常高兴地宣布 Electron 20.0.0 正式发布!你可以通过 npm install electron@latest 使用 npm 安装它,也可以从我们的 发布网站。继续阅读以了解有关此版本的详细信息,并请分享你的任何反馈!

¥The Electron team is excited to announce the release of Electron 20.0.0! You can install it with npm via npm install electron@latest or download it from our releases website. Continue reading for details about this release and please share any feedback you have!

显著变化

¥Notable Changes

新功能

¥New Features

  • 在 Windows 上添加了沉浸式暗黑模式。#34549

    ¥Added immersive dark mode on Windows. #34549

  • 添加了对类似面板行为的支持。窗口可以悬浮在全屏应用上方。#34665

    ¥Added support for panel-like behavior. Window can float over full-screened apps. #34665

  • 更新了 Windows Control Overlay 按钮,使其在 Windows 11 上的外观和体验更加原生。#34888

    ¥Updated Windows Control Overlay buttons to look and feel more native on Windows 11. #34888

  • 除非指定 nodeIntegration: truesandbox: false,否则渲染器现在默认处于沙盒状态。#35125

    ¥Renderers are now sandboxed by default unless nodeIntegration: true or sandbox: false is specified. #35125

  • 在使用 nan 构建原生模块时添加了安全措施。#35160

    ¥Added safeguards when building native modules with nan. #35160

技术栈变更

¥Stack Changes

重大变更和 API 变更

¥Breaking & API Changes

以下是 Electron 20 中引入的重大变更。有关这些变更和未来变更的更多信息,请参阅 计划中的突发事件变更 页面。

¥Below are breaking changes introduced in Electron 20. More information about these and future changes can be found on the Planned Breaking Changes page.

默认更改:没有 nodeIntegration: true 的渲染器默认被沙箱化

¥Default Changed: renderers without nodeIntegration: true are sandboxed by default

以前,指定预加载脚本的渲染器默认为未沙箱化。这意味着默认情况下,预加载脚本可以访问 Node.js。在 Electron 20 中,这个默认值已经改变。从 Electron 20 开始,渲染器将默认被沙箱化,除非指定了 nodeIntegration: truesandbox: false

¥Previously, renderers that specified a preload script defaulted to being unsandboxed. This meant that by default, preload scripts had access to Node.js. In Electron 20, this default has changed. Beginning in Electron 20, renderers will be sandboxed by default, unless nodeIntegration: true or sandbox: false is specified.

如果你的预加载脚本不依赖于 Node,则无需执行任何操作。如果你的预加载脚本确实依赖于 Node,请重构它们以从渲染器中删除 Node 使用,或者为相关渲染器显式指定 sandbox: false

¥If your preload scripts do not depend on Node, no action is needed. If your preload scripts do depend on Node, either refactor them to remove Node usage from the renderer, or explicitly specify sandbox: false for the relevant renderers.

已修复:nan 原生模块自发崩溃

¥Fixed: spontaneous crashing in nan native modules

在 Electron 20 中,我们更改了两项与原生模块相关的内容:

¥In Electron 20, we changed two items related to native modules:

  1. V8 的头文件现在默认使用 c++17。此标志已添加到 electron-rebuild 中。

    ¥V8 headers now use c++17 by default. This flag was added to electron-rebuild.

  2. 我们修复了缺少 include 会导致依赖于 nan 的原生模块自发崩溃的问题。

    ¥We fixed an issue where a missing include would cause spontaneous crashing in native modules that depended on nan.

为了获得最高的稳定性,我们建议在重新构建原生模块(尤其是依赖于 nan 的模块)时使用 node-gyp >=8.4.0 和 electron-rebuild >=3.2.9。请参阅 electron #35160 和 node-gyp #2497 了解更多信息。

¥For the most stability, we recommend using node-gyp >=8.4.0 and electron-rebuild >=3.2.9 when rebuilding native modules, particularly modules that depend on nan. See electron #35160 and node-gyp #2497 for more information.

删除:Linux 上的 .skipTaskbar

¥Removed: .skipTaskbar on Linux

在 X11 上,skipTaskbar 向 X11 窗口管理器发送 _NET_WM_STATE_SKIP_TASKBAR 消息。Wayland 没有直接的等效项,并且已知的解决方法具有不可接受的权衡(例如 GNOME 中的 Window.is_skip_taskbar 需要不安全模式),因此 Electron 无法在 Linux 上支持此功能。

¥On X11, skipTaskbar sends a _NET_WM_STATE_SKIP_TASKBAR message to the X11 window manager. There is not a direct equivalent for Wayland, and the known workarounds have unacceptable tradeoffs (e.g. Window.is_skip_taskbar in GNOME requires unsafe mode), so Electron is unable to support this feature on Linux.

17.x.y 支持终止

¥End of Support for 17.x.y

Electron 17.x.y 已根据项目 支持政策 终止支持。建议开发者和应用升级到较新版本的 Electron。

¥Electron 17.x.y has reached end-of-support as per the project's support policy. Developers and applications are encouraged to upgrade to a newer version of Electron.

E18 (2022 年 3 月)E19 (2022 年 5 月)E20 (2022 年 8 月)E21 (2022 年 9 月)E22 (2022 年 12 月)
18.x.y19.x.y20.x.y21.x.y22.x.y
17.x.y18.x.y19.x.y20.x.y21.x.y
16.x.y17.x.y18.x.y19.x.y20.x.y
15.x.y--------

下一步计划

¥What's Next

短期内,你可以预期团队将继续专注于跟上构成 Electron 的主要组件(包括 Chromium、Node 和 V8)的开发。虽然我们谨慎地不对发布日期做出承诺,但我们计划大约每两个月发布一次 Electron 的新主要版本及其组件的新版本。

¥In the short term, you can expect the team to continue to focus on keeping up with the development of the major components that make up Electron, including Chromium, Node, and V8. Although we are careful not to make promises about release dates, our plan is to release new major versions of Electron with new versions of those components approximately every 2 months.

你可以找到 Electron 公开时间线

¥You can find Electron's public timeline here.

有关未来变更的更多信息,请参阅 计划中的突发事件变更 页面。

¥More information about future changes can be found on the Planned Breaking Changes page.