Skip to main content

Electron 20.0.0

· 7 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 使用 npm install electron@latest 安装,或者从我们的 发布网站 下载。继续阅读以了解此版本的详细信息,并请分享你的任何反馈意见!

🌐 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!

新功能

🌐 New Features

  • 在 Windows 上添加了沉浸式夜间模式。#34549
  • 新增对面板式行为的支持。窗口可以浮于全屏应用之上。 #34665
  • 已更新 Windows 控制覆盖按钮,使其在 Windows 11 上看起来和使用起来更本地化。#34888
  • 渲染器现在默认被沙箱化,除非指定了 nodeIntegration: truesandbox: false#35125
  • 在使用 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 中。
  2. 我们修复了缺少 include 会导致依赖于 nan 的原生模块自发崩溃的问题。

为了获得最佳稳定性,我们建议在重建本地模块时使用 node-gyp >=8.4.0 和 electron-rebuild >=3.2.9,特别是依赖 nan 的模块。更多信息请参见 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.