Skip to main content

Electron 9.0.0

· 10 min read

Electron 9.0.0 现已发布!它包含对 Chromium 83、V8 8.3 和 Node.js 12.14 的升级。我们为拼写检查功能添加了几个新的 API 集成,启用了 PDF 查看器等等!

¥Electron 9.0.0 has been released! It includes upgrades to Chromium 83, V8 8.3, and Node.js 12.14. We've added several new API integrations for our spellchecker feature, enabled PDF viewer, and much more!


Electron 团队非常高兴地宣布 Electron 9.0.0 正式发布!你可以通过 npm install electron@latest 使用 npm 安装它,也可以从我们的 发布网站。此版本包含升级、修复和新功能。我们迫不及待地想看看你使用它们构建的内容!继续阅读以了解有关此版本的详细信息,并请分享你的任何反馈!

¥The Electron team is excited to announce the release of Electron 9.0.0! You can install it with npm via npm install electron@latest or download it from our releases website. The release is packed with upgrades, fixes, and new features. We can't wait to see what you build with them! Continue reading for details about this release, and please share any feedback you have!

显著变化

¥Notable Changes

技术栈变更

¥Stack Changes

亮点功能

¥Highlight Features

  • 拼写检查功能有多项改进。请参阅 #22128#22368 中的更多详细信息。

    ¥Multiple improvements to the spellchecker feature. See more details in #22128 and #22368.

  • 提高了 Linux 上窗口事件处理程序的效率。#23260

    ¥Improved window events handler efficiency on Linux. #23260.

  • 启用 PDF 查看器。#22131

    ¥Enable PDF viewer. #22131.

请参阅 9.0.0 发行说明 获取新功能和变更的完整列表。

¥See the 9.0.0 release notes for a full list of new features and changes.

重大变化

¥Breaking Changes

  • 使用 remote 而不使用 enableRemoteModule: true 时,会发出弃用警告。#21546

    ¥Deprecation warning when using remote without enableRemoteModule: true. #21546

    • 这是我们弃用 remote 模块并将其移至用户态的计划的第一步。你可以阅读并关注 这个问题,其中详细说明了我们这样做的原因,并包含建议的弃用时间表。

      ¥This is the first step in our plans for deprecating the remote module and moving it to userland. You can read and follow this issue that details our reasons for this and includes a proposed timeline for deprecation.

  • 默认将 app.enableRendererProcessReuse 设置为 true。#22336

    ¥Set app.enableRendererProcessReuse to true by default. #22336

    • 这是为满足未来在渲染器进程中加载​​的原生 Node 模块必须是 N-API上下文感知 的要求而进行的持续工作。完整信息和拟议时间表详见 这个问题

      ¥This is continued work for a future requirement that native Node modules loaded in the renderer process be either N-API or Context Aware. Full info and proposed timeline is detailed in this issue.

  • 现在通过 IPC 发送非 JavaScript 对象会引发异常。#21560

    ¥Sending non-JavaScript objects over IPC now throws an exception. #21560

    • 此行为在 Electron 8.0 中已弃用。在 Electron 9.0 中,旧的序列化算法已被删除,发送此类不可序列化的对象现在将抛出 "无法克隆对象" 错误。

      ¥This behavior was depreciated in Electron 8.0. In Electron 9.0, the old serialization algorithm has been removed, and sending such non-serializable objects will now throw an "object could not be cloned" error.

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

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

API 变更

¥API Changes

  • shell API 变更:

    ¥shell API changes:

    • shell.openItem API 已被异步 shell.openPath API 取代。proposal

      ¥The shell.openItem API has been replaced with an asynchronous shell.openPath API. proposal

  • sessionAPI 变更:

    ¥sessionAPI changes:

    • 添加了用于在词典中列出自定义单词的 session.listWordsFromSpellCheckerDictionary API。#22128

      ¥Added session.listWordsFromSpellCheckerDictionary API to list custom words in the dictionary. #22128

    • 添加了 session.removeWordFromSpellCheckerDictionary API,用于删除词典中的自定义单词。#22368

      ¥Added session.removeWordFromSpellCheckerDictionary API to remove custom words in the dictionary. #22368

    • 添加了用于访问基本服务工作线程信息和接收来自服务工作线程的控制台日志的 session.serviceWorkerContext API。#22313

      ¥Added session.serviceWorkerContext API to access basic service worker info and receive console logs from service workers. #22313

  • app API 变更:

    ¥app API changes:

    • 在 macOS 上为 app.focus() 添加了新的 force 参数,允许应用强制获取焦点。#23447

      ¥Added a new force parameter to app.focus() on macOS to allow apps to forcefully take focus. #23447

  • BrowserWindow API 变更:

    ¥BrowserWindow API changes:

    • 添加了对 BrowserWindow 上某些 getter/setter 对的属性访问的支持。#23208

      ¥Added support for property access to some getter/setter pairs on BrowserWindow. #23208

已弃用的 API

¥Deprecated APIs

以下 API 现已弃用或删除:

¥The following APIs are now deprecated or removed:

  • shell.openItem API 现已弃用,并被异步的 shell.openPath API 取代。

    ¥shell.openItem API is now depreciated, and replaced with an asynchronous shell.openPath API.

  • <webview>.getWebContents 在 Electron 8.0 中已被弃用,现已被移除。

    ¥<webview>.getWebContents, which was deprecated in Electron 8.0, is now removed.

  • webFrame.setLayoutZoomLevelLimits 在 Electron 8.0 中已被弃用,现已被移除。

    ¥webFrame.setLayoutZoomLevelLimits, which was deprecated in Electron 8.0, is now removed.

6.x.y 停止支持

¥End of Support for 6.x.y

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

¥Electron 6.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.

下一步计划

¥What's Next

短期内,你可以预期团队将继续专注于跟上构成 Electron 的主要组件(包括 Chromium、Node 和 V8)的开发。虽然我们谨慎地不对发布日期做出承诺,但我们计划大约每季度发布一次 Electron 的新主要版本及其组件的新版本。暂定 10.0.0 计划 列出了 Electron 10.0 开发生命周期中的关键日期。此外,查看我们的版本控制文档 提供了有关 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 release new major versions of Electron with new versions of those components approximately quarterly. The tentative 10.0.0 schedule maps out key dates in the Electron 10.0 development life cycle. Also, see our versioning document for more detailed information about versioning in Electron.

有关即将推出的 Electron 版本 查看我们的“计划重大变更”文档 中计划的重大变更的信息。

¥For information on planned breaking changes in upcoming versions of Electron, see our Planned Breaking Changes doc.

contextIsolation 的默认值从 false 更改为 true(从 Electron 10 开始)

¥Change the default of contextIsolation from false to true (Starting in Electron 10)

如果没有 contextIsolation,任何在渲染器进程中运行的代码都很容易访问 Electron 内部或应用的预加载脚本。之后,该代码可以执行 Electron 想要限制的特权操作。

¥Without contextIsolation, any code running in a renderer process can quite easily reach into Electron internals or an app's preload script. That code can then perform privileged actions that Electron wants to keep restricted.

更改此默认值可提高 Electron 应用的默认安全性,因此应用需要主动启用不安全的行为。Electron 将在 Electron 10.0 中弃用当前默认的 contextIsolation,并在 Electron 12.0 中改为使用新的默认版本 (true)。

¥Changing this default improves the default security of Electron apps, so that apps will need to deliberately opt in to the insecure behaviour. Electron will depreciate the current default of contextIsolation in Electron 10.0, and change to the new default (true) in Electron 12.0.

有关 contextIsolation 的更多信息、如何轻松启用它以及它的安全优势,请参阅我们专门的 上下文隔离文档

¥For more information on contextIsolation, how to enable it easily and it's security benefits please see our dedicated Context Isolation Document.