Skip to main content

Electron 5.0.0

· 9 min read

Electron 团队很高兴地宣布 Electron 5.0.0 的发布!你可以通过 npm 使用 npm install electron@latest 安装,或从我们的发布页面下载压缩包。本次发布包含了大量升级、修复和新功能。我们迫不及待地想看看你们会用这些功能创造出什么!继续阅读以了解本次发布的详细信息,并请分享你们的任何反馈!

🌐 The Electron team is excited to announce the release of Electron 5.0.0! You can install it with npm via npm install electron@latest or download the tarballs from our releases page. 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!


有什么新功能?

🌐 What's New?

Electron 的大部分功能由 Chromium、Node.js 和 V8 的核心组件提供。Electron 会跟进这些项目的最新进展,为用户提供新的 JavaScript 功能、性能改进和安全修复。在 Electron 5 中,这些软件包中的每一个都有一次主要版本更新:

🌐 Much of Electron's functionality is provided by the core components of Chromium, Node.js, and V8. Electron keeps up-to-date with these projects to provide our users with new JavaScript features, performance improvements, and security fixes. Each of these packages has a major version bump in Electron 5:

Electron 5 还包括对 Electron 特定 API 的改进。主要更改总结如下;有关完整的更改列表,请查看 Electron v5.0.0 发布说明

🌐 Electron 5 also includes improvements to Electron-specific APIs. A summary of the major changes is below; for the full list of changes, check out the Electron v5.0.0 release notes.

Promisification

Electron 5 继续推进 Promisification initiative 计划,将 Electron 的基于回调的 API 转换为使用 Promise。这些 API 已在 Electron 5 中被转换:

🌐 Electron 5 continues Promisification initiative initiative to convert Electron's callback-based API to use Promises. These APIs were converted for Electron 5:

  • app.getFileIcon
  • contentTracing.getCategories
  • contentTracing.startRecording
  • contentTracing.stopRecording
  • debugger.sendCommand
  • Cookies API
  • shell.openExternal
  • webContents.loadFile
  • webContents.loadURL
  • webContents.zoomLevel
  • webContents.zoomFactor
  • win.capturePage

macOS 的系统颜色访问

🌐 System colors access for macOS

这些函数已被更改或添加到 systemPreferences 中,以访问 macOS 系统的颜色:

🌐 These functions were changed or added to systemPreferences to access macOS systems' colors:

  • systemPreferences.getAccentColor
  • systemPreferences.getColor
  • systemPreferences.getSystemColor

进程内存信息

🌐 Process memory information

已添加函数 process.getProcessMemoryInfo 来获取当前进程的内存使用情况统计。

🌐 The function process.getProcessMemoryInfo has been added to get memory usage statistics about the current process.

远程 API 的额外筛选功能

🌐 Additional filtering for remote APIs

为了提高 remote API 的安全性,已添加了新的远程事件,以便可以对 remote.getBuiltinremote.getCurrentWindowremote.getCurrentWebContents<webview>.getWebContents 进行过滤

🌐 To improve security in the remote API, new remote events have been added so that remote.getBuiltin, remote.getCurrentWindow, remote.getCurrentWebContents and <webview>.getWebContents can be filtered.

浏览器窗口上的多个浏览器视图

🌐 Multiple BrowserViews on BrowserWindow

BrowserWindow 现在支持在同一个 BrowserWindow 中管理多个 BrowserView。

🌐 BrowserWindow now supports managing multiple BrowserViews within the same BrowserWindow.

重大变化

🌐 Breaking Changes

打包应用的默认值

🌐 Defaults for packaged apps

打包的应用现在将与默认应用表现相同:除非应用已有菜单,否则将创建默认应用菜单;除非应用自行处理事件,否则 window-all-closed 事件将被自动处理。

🌐 Packaged apps will now behave the same as the default app: a default application menu will be created unless the app has one and the window-all-closed event will be automatically handled unless the app handles the event.

混合沙盒

🌐 Mixed sandbox

混合沙箱模式现在默认启用。使用 sandbox: true 启动的渲染器现在将真正处于沙箱环境中,而之前只有在也启用了混合沙箱模式时,它们才会被沙箱化。

🌐 Mixed sandbox mode is now enabled by default. Renderers launched with sandbox: true will now be actually sandboxed, where previously they would only be sandboxed if mixed-sandbox mode was also enabled.

安全性改进

🌐 Security improvements

nodeIntegrationwebviewTag 的默认值现在为 false,以提高安全性。

🌐 The default values of nodeIntegration and webviewTag are now false to improve security.

拼写检查器现在异步

🌐 Spellchecker now asynchronous

SpellCheck API 已经更改为提供异步结果

🌐 The SpellCheck API has been changed to provide asynchronous results.

弃用

🌐 Deprecations

以下 API 在 Electron 5.0.0 中被弃用,并计划在 6.0.0 中删除:

🌐 The following APIs are newly deprecated in Electron 5.0.0 and planned for removal in 6.0.0:

适用于 arm 和 arm64 的 Mksnapshot 二进制文件

🌐 Mksnapshot binaries for arm and arm64

mksnapshot 的 ARM 和 ARM64 原生二进制文件已被弃用,并将在 6.0.0 中移除。可以使用 x64 二进制文件为 ARM 和 ARM64 创建快照。

🌐 Native binaries of mksnapshot for arm and arm64 are deprecated and will be removed in 6.0.0. Snapshots can be created for arm and arm64 using the x64 binaries.

WebContents 上的 ServiceWorker API

🌐 ServiceWorker APIs on WebContents

已弃用 WebContents 上的 ServiceWorker API,准备将其移除。

🌐 Deprecated ServiceWorker APIs on WebContents in preparation for their removal.

  • webContents.hasServiceWorker
  • webContents.unregisterServiceWorker

带有沙盒 webContents 的自动模块

🌐 Automatic modules with sandboxed webContents

为了提高安全性,以下模块将不再通过 require 直接使用,而需要通过 remote.require 在沙盒化的 webcontents 中引入:

🌐 In order to improve security, the following modules are being deprecated for use directly via require and will instead need to be included via remote.require in a sandboxed webcontents:

  • electron.screen
  • child_process
  • fs
  • os
  • path

webFrame 隔离世界 API

🌐 webFrame Isolated World APIs

webFrame.setIsolatedWorldContentSecurityPolicywebFrame.setIsolatedWorldHumanReadableNamewebFrame.setIsolatedWorldSecurityOrigin 已被弃用,建议使用 webFrame.setIsolatedWorldInfo

混合沙盒

🌐 Mixed sandbox

enableMixedSandbox--enable-mixed-sandbox 命令行开关仍然存在以保持兼容性,但已不推荐使用且不起作用。

2.0.x 停止支持

🌐 End of support for 2.0.x

根据我们的支持版本政策,2.0.x 已经终止支持。

🌐 Per our supported versions policy, 2.0.x has reached end of life.

应用反馈计划

🌐 App Feedback Program

我们继续使用我们的应用反馈计划进行测试。参与该计划的项目会在他们的应用上测试 Electron 测试版;作为回报,他们发现的新问题会被优先处理用于正式版本。如果你想参与或了解更多信息,请查看我们关于该计划的博客文章

🌐 We continue to use our App Feedback Program for testing. Projects who participate in this program test Electron betas on their apps; and in return, the new bugs they find are prioritized for the stable release. If you'd like to participate or learn more, check out our blog post about the program.

下一步计划

🌐 What's Next

在短期内,你可以预期团队将继续专注于跟进构成 Electron 的主要组件的发展,包括 Chromium、Node 和 V8。虽然我们谨慎地不对发布日期做出承诺,但我们的计划是在大约每季度发布一次包含这些组件新版本的 Electron 主要版本。暂定的 6.0.0 计划 列出了 Electron 6 开发生命周期中的关键日期。此外,请参阅我们的版本说明文档 以获取关于 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 6.0.0 schedule maps out key dates in the Electron 6 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.