Electron 14.0.0
Electron 14.0.0 已经发布!它包括对 Chromium 93 和 V8 9.3 的升级。我们新增了多个 API 更新、修复了若干错误,并进行了整体改进。详情请阅读下面内容!
🌐 Electron 14.0.0 has been released! It includes upgrades to Chromium 93 and V8 9.3. We've added several API updates, bug fixes, and general improvements. Read below for more details!
Electron 团队很高兴地宣布 Electron 14.0.0 正式发布!你可以通过 npm 使用 npm install electron@latest 安装,或者从我们的发布网站下载。继续阅读了解本次发布的详细信息,并欢迎分享你的任何反馈!
🌐 The Electron team is excited to announce the release of Electron 14.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 发布节奏变更
🌐 Electron Release Cadence Change
从 2021 年 9 月的 Electron 15 开始,Electron 将每 8 周发布一个新的主要稳定版本。你可以在此处阅读完整详情。
Electron 15 的测试版将于 2021 年 9 月 1 日开始,稳定版将于 2021 年 9 月 21 日发布。你可以在此处查看 Electron 的公开时间表。
此外,Electron 将把受支持的版本从最近三个版本更改为最近四个版本,直到 2022 年 5 月。关于 Electron 版本的更多详细信息,请参见我们的版本管理文档。
🌐 Beginning in September 2021 with Electron 15, Electron will release a new major stable version every 8 weeks. You can read the full details here. Electron 15 will begin beta on September 1, 2021 and stable release will be on September 21, 2021. You can find Electron's public timeline here. 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.
显著变化
🌐 Notable Changes
- 默认已更改:
nativeWindowOpen现在默认为true。(查看文档) - 子窗口不再继承其父窗口的 BrowserWindow 构造选项。 #28550
- 新增
session.storagePathAPI,用于获取会话特定数据在磁盘上的路径。 #28665 - 添加了
process.contextId,由@electron/remote使用。 #28007 - 在 Electron Fuse 后添加了实验性的 cookie 加密支持。 #29492
请查看 14.0.0 版本说明 以获取完整的新功能和更改列表。
🌐 See the 14.0.0 release notes for a full list of new features and changes.
技术栈变更
🌐 Stack Changes
- Chromium
93 - Node.js
14.17.0 - V8
9.3
重大变化
🌐 Breaking Changes
以下是 Electron 14 中引入的重大变更。有关这些变更以及未来变更的更多信息,可以参阅计划中的重大变更页面。
🌐 Below are breaking changes introduced in Electron 14. More information about these and future changes can be found on the Planned Breaking Changes page.
已移除:app.allowRendererProcessReuse
🌐 Removed: app.allowRendererProcessReuse
app.allowRendererProcessReuse 属性已被移除,这是我们计划的一部分,旨在使安全性、性能和可维护性方面更紧密地与 Chromium 的进程模型保持一致。
🌐 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。
🌐 For more detailed information see #18397.
已移除:浏览器窗口关联
🌐 Removed: Browser Window Affinity
在构建新的 BrowserWindow 时,affinity 选项已被移除,这是我们为了在安全性、性能和可维护性方面与 Chromium 的进程模型更紧密对齐的计划的一部分。
🌐 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。
🌐 For more detailed information see #18397.
API 已更改:window.open()
🌐 API Changed: window.open()
可选参数 frameName 不再设置窗口标题。此行为现在遵循 原生文档 中关于 windowName 参数的规范。
🌐 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.
如果你使用此参数来设置窗口标题,你可以改用 win.setTitle(title) 方法。
🌐 If you were using this parameter to set the title of a window, you can instead
use the win.setTitle(title)
method.
已移除:worldSafeExecuteJavaScript
🌐 Removed: worldSafeExecuteJavaScript
worldSafeExecuteJavaScript 已被移除,且没有替代选项。请确保你的代码在启用此属性的情况下能够正常工作。自 Electron 12 起,该属性默认已启用。
如果你使用 webFrame.executeJavaScript 或 webFrame.executeJavaScriptInIsolatedWorld,将会受到此更改的影响。你需要确保这两种方法返回的值被 Context Bridge API 支持,因为这些方法使用相同的值传递语义。
🌐 You will be affected by this change if you use either webFrame.executeJavaScript or webFrame.executeJavaScriptInIsolatedWorld. You will need to ensure that values returned by either of those methods are supported by the Context Bridge API as these methods use the same value passing semantics.
默认已更改:nativeWindowOpen 默认值为 true
🌐 Default Changed: nativeWindowOpen defaults to true
在 Electron 14 之前,window.open 默认被用作 BrowserWindowProxy 的替代。这意味着 window.open('about:blank') 无法同步打开可脚本化的子窗口,以及其他不兼容的问题。nativeWindowOpen 不再是实验性的,现在已成为默认设置。
🌐 Prior to Electron 14, window.open was by default shimmed to use
BrowserWindowProxy. This meant that window.open('about:blank') did not work
to open synchronously scriptable child windows, among other incompatibilities.
nativeWindowOpen is no longer experimental, and is now the default.
有关更多详细信息,请参阅 Electron 中的 window.open 文档。
🌐 See the documentation for window.open in Electron for more details.
已移除:BrowserWindowConstructorOptions 继承自父窗口
🌐 Removed: BrowserWindowConstructorOptions inheriting from parent windows
在 Electron 14 之前,使用 window.open 打开的窗口会继承其父窗口的 BrowserWindow 构造选项,例如 transparent 和 resizable。从 Electron 14 开始,这种行为已被移除,窗口将不会从其父窗口继承任何 BrowserWindow 构造选项。
🌐 Prior to Electron 14, windows opened with window.open would inherit
BrowserWindow constructor options such as transparent and resizable from
their parent window. Beginning with Electron 14, this behavior has been removed
and windows will not inherit any BrowserWindow constructor options from their
parents.
相反,可以使用 setWindowOpenHandler 显式设置新窗口的选项:
🌐 Instead, explicitly set options for the new window with setWindowOpenHandler:
webContents.setWindowOpenHandler((details) => {
return {
action: 'allow',
overrideBrowserWindowOptions: {
// ...
},
};
});
已移除:additionalFeatures
🌐 Removed: additionalFeatures
WebContents 的 new-window 和 did-create-window 事件中的已弃用 additionalFeatures 属性已被移除。由于 new-window 使用位置参数,该参数仍然存在,但始终将是空数组 []。(注意:new-window 事件本身已经被弃用,并已被 setWindowOpenHandler 取代。)窗口特性中的裸键现在将在选项对象中以值为 true 的键形式呈现。
🌐 The deprecated additionalFeatures property in the new-window and
did-create-window events of WebContents has been removed. Since new-window
uses positional arguments, the argument is still present, but will always be
the empty array []. (Note: the new-window event itself is already
deprecated and has been replaced by setWindowOpenHandler.) Bare keys in window
features will now present as keys with the value true in the options object.
// Removed in 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 模块
🌐 Removed: remote module
在 Electron 12 中已弃用的 remote 模块现已从 Electron 本身移除,并提取到一个单独的包 @electron/remote 中。@electron/remote 模块用于在主进程和渲染进程之间桥接 JavaScript 对象。它允许你像在渲染进程中一样访问仅在主进程中可用的对象。这是 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 变更
🌐 API Changes
- 添加了
BrowserWindow.isFocusable()方法来判断窗口是否可获取焦点。 #28642 - 添加了
WebFrameMain.visibilityState实例属性。 #28706 - 已将
disposition、referrer和postBody添加到传递给通过setWindowOpenHandler注册的 window 打开处理程序的详细信息对象中。#28518 - 添加了
process.contextId,由@electron/remote使用。 #28007 - 在 Electron Fuse 后添加了实验性的 cookie 加密支持。 #29492
- 为
webRequest监听器详情添加了缺失的resourceType转换:font、ping、cspReport、media、webSocket。#30050 - 新增
session.storagePathAPI,用于获取会话特定数据在磁盘上的路径。 #28665 - 在 macOS 上增加了对 Windows 控制覆盖的支持。 #29986
- 增加了使用
--log-file=.../path/to/file.log将 Chromium 日志导向文件的支持。此外,现在可以通过在第一个 JS 周期附加命令行开关来启用 JavaScript 日志记录。 #29963 - 在 Node Crypto 中新增了对 des-ede3 加密算法的支持。 #27897
- 新增了
ContextBridgeMutability功能,允许修改上下文桥接对象。 #27348
移除/弃用的变更
🌐 Removed/Deprecated Changes
以下 API 已被删除或弃用:
🌐 The following APIs have been removed or are now deprecated:
remote模块在 Electron 12 中被弃用后已被移除。 #25734- 子窗口不再继承其父窗口的 BrowserWindow 构造选项。 #28550
- 从
new-window和did-create-window的 WebContents 事件中移除了已弃用的additionalFeatures属性。#28548 - 已移除已弃用的
app.allowRendererProcessReuse和 BrowserWindowaffinity选项。#26874 - 当
uploadToServer为 false 时,crashReporter.start的submitURL选项不再是必需参数。 #28105
11.x.y 终止支持
🌐 End of Support for 11.x.y
根据项目的支持政策,Electron 11.x.y 已达到支持结束。建议开发者和应用升级到更新版本的 Electron。
🌐 Electron 11.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 重大版本。
🌐 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.
有关即将发布的 Electron 版本中计划的重大更改的信息,请参阅我们的 计划中的重大更改。
🌐 For information on planned breaking changes in upcoming versions of Electron, see our Planned Breaking Changes.