跳转到主内容

Electron 14.0.0

· 阅读时间:约 7 分钟

Electron 14.0.0 已发布! 它包括了到 Chromium 93 和 V8 9.3 的更新。 我们添加了多个 API 更新、错误修复和一般改进。 请阅读下文了解更多详情!


Electron 团队很高兴发布了 Electron 14.0.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!

重要变化

Electron 发布时间变更

Beginning in September 2021 with Electron 15, Electron will release a new major stable version every 8 weeks. 您可以在此处阅读 完整详细信息。 Electron 15 will begin beta on September 1, 2021 and stable release will be on September 21, 2021. 您可以在此处找到 Electron 的公开时间表。 Additionally, Electron will be changing supported versions from latest three versions to latest four versions until May 2022. See see our versioning document for more detailed information about versioning in Electron.

架构(Stack)更新

Highlight Features

  • Default Changed: nativeWindowOpen now defaults to true. (see docs)
  • Child windows no longer inherit BrowserWindow construction options from their parents. #28550
  • Added new session.storagePath API to get the path on disk for session-specific data. #28665
  • Added process.contextId used by @electron/remote. #28007
  • Added experimental cookie encryption support behind an Electron Fuse. #29492

有关新功能和变更的完整列表,请参阅 14.0.0 发布通知

重大更改

以下是 Electron 14 中引入的破坏性变更。 More information about these and future changes can be found on the Planned Breaking Changes page.

已移除: app.allowRendererProcessReuse

The app.allowRendererProcessReuse property has been removed as part of our plan to more closely align with Chromium's process model for security, performance and maintainability.

更多信息见:#18397

移除: Browser Window Affinity

The affinity option when constructing a new BrowserWindow has been removed as part of our plan to more closely align with Chromium's process model for security, performance and maintainability.

更多信息见:#18397

API 更改: window.open()

The optional parameter frameName no longer sets the title of the window. This behavior now follows the specification described by the native documentation for the windowName parameter.

If you were using this parameter to set the title of a window, you can instead use the win.setTitle(title) method.

已移除: worldSafeExecuteJavaScript

worldSafeExecuteJavaScript has been removed with no alternative. Please ensure your code works with this property enabled. It has been enabled by default since Electron 12.

若您使用了 webFrame.executeJavaScriptwebFrame.executeJavaScriptInIsolatedWorld,这个改动会对您造成影响。 您将需要确保这些方法中任何一种返回的值都被 Context Bridge API 支持,因为这些方法使用相同的值传递语意。

默认更改: nativeWindowOpen 默认为 true

在 Electron 14之前, window.open 默认使用 BrowserWindowProxy。 这意味着 window.open('about:blank') 无法再来打开可同步脚本的子窗口,以及其他不兼容的情况。 nativeWindowOpen 不再是实验性的,现在是默认值

更多详细信息: window.open

移除: 从父窗口继承的 BrowserWindowConstructorOptions

在Electron 14之前,使用 window.open 打开的窗口将继承 BrowserWindow构造函数选项,例如 transparentresizable ,这些选项来自其父窗口 。 Beginning with Electron 14, this behavior has been removed and windows will not inherit any BrowserWindow constructor options from their parents.

相反,请使用 setWindowOpenHandler显式设置新窗口的选项:

webContents.setWindowOpenHandler((details) => {
return {
action: 'allow',
overrideBrowserWindowOptions: {
// ...
},
};
});

已移除: additionalFeatures

WebContents 的 new-windowdid-create-window 事件中已弃用的 additionalFeatures 属性已被删除。 由于 new-window 使用 positional 参数,因此该参数仍然存在,但始终 空数组 []。 (Note: the new-window event itself is already deprecated and has been replaced by setWindowOpenHandler.) 窗口功能中的 Bare keys 现在会显示为选项对象中值为 true 的 key。

// 在 Electron 14 移除
// Triggered by window.open('...', '', 'my-key')
webContents.on('did-create-window', (window, details) => {
if (details.additionalFeatures.includes('my-key')) {
// ...
}
});

// Replace with
webContents.on('did-create-window', (window, details) => {
if (details.options['my-key']) {
// ...
}
});

移除: remote 模块

Deprecated in Electron 12, the remote module has now been removed from Electron itself and extracted into a separate package, @electron/remote. The @electron/remote module bridges JavaScript objects from the main process to the renderer process. This lets you access main-process-only objects as if they were available in the renderer process. This is a direct replacement for the remote module. See the module's readme for migration instructions and reference.

API 更改

  • Added BrowserWindow.isFocusable() method to determine whether a window is focusable. #28642
  • Added WebFrameMain.visibilityState instance property. #28706
  • Added disposition, referrer and postBody to the details object passed to the window open handler registered with setWindowOpenHandler. #28518
  • Added process.contextId used by @electron/remote. #28007
  • Added experimental cookie encryption support behind an Electron Fuse. #29492
  • Added missing resourceType conversions for webRequest listener details: font, ping, cspReport, media, webSocket. #30050
  • Added new session.storagePath API to get the path on disk for session-specific data. #28665
  • Added support for Windows Control Overlay on macOS. #29986
  • Added support for directing Chromium logging to a file with --log-file=.../path/to/file.log. Also, it's now possible to enable logging from JavaScript by appending command-line switches during the first JS tick. #29963
  • Added support for the des-ede3 cipher in node crypto. #27897
  • Added a ContextBridgeMutability feature that allows context bridge objects to be mutated. #27348

Removed/Deprecated Changes

The following APIs have been removed or are now deprecated:

  • The remote module has been removed after being deprecated in Electron 12. #25734
  • Child windows no longer inherit BrowserWindow construction options from their parents. #28550
  • Removed deprecated additionalFeatures property from new-window and did-create-window WebContents events. #28548
  • Removed the deprecated app.allowRendererProcessReuse and BrowserWindow affinity options. #26874
  • The submitURL option for crashReporter.start is no longer a required argument when uploadToServer is false. #28105

终止对 11.x.y 的支持

根据项目的支持政策,Electron 11.x.y 已经达到了支持的终点。 我们鼓励开发者将应用程序升级到更新的 Electron 版本。

接下来

在短期内,您可以期待团队继续专注于跟上构成 Electron 的主要组件的开发,包括 Chromium、Node 和 V8。 尽管我们谨慎地避免对发布日期做出承诺,但我们的计划是大约每季度发布一次 Electron 的新主要版本以及这些组件的新版本。

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