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 install electron@latest
使用 npm 安装它,也可以从我们的 发布网站。继续阅读以了解有关此版本的详细信息,并请分享你的任何反馈!
¥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!
显著变化
¥Notable Changes
Electron 发布节奏变更
¥Electron Release Cadence Change
从 2021 年 9 月的 Electron 15 开始,Electron 将每 8 周发布一个新的主要稳定版本。你可以阅读 完整详情请见此处。Electron 15 将于 2021 年 9 月 1 日开始 Beta 测试,稳定版本将于 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.
技术栈变更
¥Stack Changes
-
Chromium
93
-
Node.js
14.17.0
-
V8
9.3
亮点功能
¥Highlight Features
-
默认更改:
nativeWindowOpen
现在默认为true
。(查看文档)¥Default Changed:
nativeWindowOpen
now defaults totrue
. (see docs) -
子窗口不再从其父窗口继承 BrowserWindow 的构造选项。#28550
¥Child windows no longer inherit BrowserWindow construction options from their parents. #28550
-
添加了新的
session.storagePath
API,用于获取会话特定数据在磁盘上的路径。#28665¥Added new
session.storagePath
API to get the path on disk for session-specific data. #28665 -
已添加
@electron/remote
使用的process.contextId
。#28007¥Added
process.contextId
used by@electron/remote
. #28007 -
在 Electron Fuse 后面添加了实验性 Cookie 加密支持。#29492
¥Added experimental cookie encryption support behind an Electron Fuse. #29492
请参阅 14.0.0 发行说明 获取新功能和变更的完整列表。
¥See the 14.0.0 release notes for a full list of new features and changes.
重大变化
¥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
为了更紧密地与 Chromium 的进程模型保持一致,在安全性、性能和可维护性方面,我们计划在构建新的 BrowserWindow
时移除 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。
¥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 开始它就被默认启用。
¥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.executeJavaScript
或 webFrame.executeJavaScriptInIsolatedWorld
,你将受到此更改的影响。你需要确保 上下文桥 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
remote
模块在 Electron 12 中已弃用,现已从 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¥Added
BrowserWindow.isFocusable()
method to determine whether a window is focusable. #28642 -
添加了
WebFrameMain.visibilityState
实例属性。#28706¥Added
WebFrameMain.visibilityState
instance property. #28706 -
已将
disposition
、referrer
和postBody
添加到传递给在setWindowOpenHandler
注册的窗口打开处理程序的详细信息对象中。#28518¥Added
disposition
,referrer
andpostBody
to the details object passed to the window open handler registered withsetWindowOpenHandler
. #28518 -
已添加
@electron/remote
使用的process.contextId
。#28007¥Added
process.contextId
used by@electron/remote
. #28007 -
在 Electron Fuse 后面添加了实验性 Cookie 加密支持。#29492
¥Added experimental cookie encryption support behind an Electron Fuse. #29492
-
为
webRequest
监听器详情添加了缺失的resourceType
转换:font
、ping
、cspReport
、media
、webSocket
。#30050¥Added missing
resourceType
conversions forwebRequest
listener details:font
,ping
,cspReport
,media
,webSocket
. #30050 -
添加了新的
session.storagePath
API,用于获取会话特定数据在磁盘上的路径。#28665¥Added new
session.storagePath
API to get the path on disk for session-specific data. #28665 -
添加了对 macOS 上 Windows 控件覆盖层的支持。#29986
¥Added support for Windows Control Overlay on macOS. #29986
-
添加了使用
--log-file=.../path/to/file.log
将 Chromium 日志记录定向到文件的支持。此外,现在可以通过在第一个 JS tick 期间附加命令行开关来启用 JavaScript 日志记录。#29963¥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 -
在 Node Crypto 中添加了对 des-ede3 密码的支持。#27897
¥Added support for the des-ede3 cipher in node crypto. #27897
-
添加了
ContextBridgeMutability
功能,允许修改上下文桥接对象。#27348¥Added a
ContextBridgeMutability
feature that allows context bridge objects to be mutated. #27348
移除/弃用的变更
¥Removed/Deprecated Changes
以下 API 已被删除或弃用:
¥The following APIs have been removed or are now deprecated:
-
remote
模块在 Electron 12 中被弃用后已被移除。#25734¥The
remote
module has been removed after being deprecated in Electron 12. #25734 -
子窗口不再从其父窗口继承 BrowserWindow 的构造选项。#28550
¥Child windows no longer inherit BrowserWindow construction options from their parents. #28550
-
从
new-window
和did-create-window
WebContents 事件中移除了已弃用的additionalFeatures
属性。#28548¥Removed deprecated
additionalFeatures
property fromnew-window
anddid-create-window
WebContents events. #28548 -
移除了已弃用的
app.allowRendererProcessReuse
和 BrowserWindowaffinity
选项。#26874¥Removed the deprecated
app.allowRendererProcessReuse
and BrowserWindowaffinity
options. #26874 -
当
uploadToServer
为 false 时,crashReporter.start
的submitURL
选项不再是必需参数。#28105¥The
submitURL
option forcrashReporter.start
is no longer a required argument whenuploadToServer
is false. #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.