Skip to main content

Electron 12.0.0

· 12 min read

Electron 12.0.0 已发布!它包含对 Chromium 89、V8 8.9 和 Node.js 14.16 的升级。我们添加了 remote 模块的更改、contextIsolation 的新默认值、新的 webFrameMain API 以及常规改进。请阅读下文了解更多详情!

¥Electron 12.0.0 has been released! It includes upgrades to Chromium 89, V8 8.9 and Node.js 14.16. We've added changes to the remote module, new defaults for contextIsolation, a new webFrameMain API, and general improvements. Read below for more details!


Electron 团队非常高兴地宣布 Electron 12.0.0 正式发布!你可以通过 npm install electron@latest 使用 npm 安装它,也可以从我们的 发布网站。继续阅读以了解有关此版本的详细信息,并请分享你的任何反馈!

¥The Electron team is excited to announce the release of Electron 12.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

技术栈变更

¥Stack Changes

亮点功能

¥Highlight Features

  • ContextBridge exposeInMainWorld 方法现在可以公开非对象 API。#26834

    ¥The ContextBridge exposeInMainWorld method can now expose non-object APIs. #26834

  • 已从 Node 12 升级到 Node 14。#23249

    ¥Upgraded from Node 12 to Node 14. #23249

  • 添加了新的 webFrameMain API,用于从主进程访问 WebContents 实例的子框架。#25464

    ¥Added a new webFrameMain API for accessing sub-frames of a WebContents instance from the main process. #25464

  • contextIsolationworldSafeExecuteJavaScript 的默认值现已改为 true#27949 #27502

    ¥The default values of contextIsolation and worldSafeExecuteJavaScript are now true. #27949 #27502

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

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

重大变化

¥Breaking Changes

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

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

API 变更

¥API Changes

  • 添加了 webFrameMain API:webFrameMain 模块可用于在现有的 WebContents 实例中查找框架。这是现有 webFrame API 的主要流程等效部分。更多关于此新 API 的信息,请参阅 此处 和我们的 documentation

    ¥Added webFrameMain API: The webFrameMain module can be used to look up frames across existing WebContents instances. This is the main process equivalent of the existing webFrame API. More information about this new API can be found here, and in our documentation.

  • app API 变更:

    ¥app API changes:

    • 'child-process-gone' / app.getAppMetrics() 添加了非本地化的 serviceName#25975

      ¥Added non-localized serviceName to 'child-process-gone' / app.getAppMetrics(). #25975

    • 添加了新的 app.runningUnderRosettaTranslation 属性,用于检测何时在 Apple Silicon 上的 Rosetta 下运行。#26444

      ¥Added new app.runningUnderRosettaTranslation property to detect when running under rosetta on Apple silicon. #26444

    • render-process-gone 详细信息中添加了 exitCode(应用和 Web 内容)。#27677

      ¥Added exitCode to render-process-gone details (app & webContents). #27677

  • BrowserWindow API 变更:

    ¥BrowserWindow API changes:

    • 添加了 BrowserWindow.isTabletMode() API。#25209

      ¥Added BrowserWindow.isTabletMode() API. #25209

    • BrowserWindow 中添加了 resized (Windows/macOS) 和 moved (Windows) 事件。#26216

      ¥Added resized (Windows/macOS) and moved (Windows) events to BrowserWindow. #26216

    • 添加了新的 system-context-menu 事件,用于阻止和覆盖系统上下文菜单。#25795

      ¥Added new system-context-menu event to allow preventing and overriding the system context menu. #25795

    • 添加 win.setTopBrowserView() 以便可以触发 BrowserView#27713

      ¥Added win.setTopBrowserView() so that BrowserViews can be raised. #27713

    • 添加 webPreferences.preferredSizeMode 以允许根据文档的最小大小调整视图大小。#25874

      ¥Added webPreferences.preferredSizeMode to allow sizing views according to their document's minimum size. #25874

  • contextBridge API 变更:

    ¥contextBridge API changes:

    • 允许 ContextBridge exposeInMainWorld 方法公开非对象 API。#26834

      ¥Allowed ContextBridge exposeInMainWorld method to expose non-object APIs. #26834

  • display API 变更:

    ¥display API changes:

    • Display 对象中添加了 displayFrequency 属性,以便获取 Windows 上刷新率的信息。#26472

      ¥Added displayFrequency property to the Display object to allow getting information about the refresh rate on Windows. #26472

  • extensions API 变更:

    ¥extensions API changes:

    • 添加了对某些 chrome.management API 的支持。#25098

      ¥Added support for some chrome.management APIs. #25098

  • MenuItem API 变更:

    ¥MenuItem API changes:

    • 添加了对显示 macOS 共享菜单的支持。#25629

      ¥Added support for showing macOS share menu. #25629

  • net API 变更:

    ¥net API changes:

    • net.request() 添加了新的 credentials 选项。#25284

      ¥Added a new credentials option for net.request(). #25284

    • 添加了 net.online,用于检测当前是否有互联网连接。#21004

      ¥Added net.online for detecting whether there is currently internet connection. #21004

  • powerMonitor API 变更:

    ¥powerMonitor API changes:

    • 添加了 powerMonitor.onBatteryPower#26494

      ¥Added powerMonitor.onBatteryPower. #26494

    • 在 macOS 上为 powerMonitor 添加了快速用户切换事件。#25321

      ¥Added fast user switching event to powerMonitor on macOS. #25321

  • session API 变更:

    ¥session API changes:

    • ses.loadExtension() API 中添加了 allowFileAccess 选项。#27702

      ¥Added allowFileAccess option to ses.loadExtension() API. #27702

    • session.setPermissionRequestHandler 添加了 display-capture API。#27696

      ¥Added display-capture API for session.setPermissionRequestHandler. #27696

    • session.setSSLConfig 中添加了 disabledCipherSuites 选项。#25818

      ¥Added a disabledCipherSuites option to session.setSSLConfig. #25818

    • 已将 extension-loadedextension-unloadedextension-ready 事件添加到 session#25385

      ¥Added extension-loaded, extension-unloaded, and extension-ready events to session. #25385

    • 添加了 session.setSSLConfig() 以允许配置 SSL。#25461

      ¥Added session.setSSLConfig() to allow configuring SSL. #25461

    • 添加了在 session.setProxy() 中明确指定 directauto_detectsystem 模式的支持。#24937

      ¥Added support for explicitly specifying direct, auto_detect or system modes in session.setProxy(). #24937

    • 添加了 串行 API 支持。#25237

      ¥Added Serial API support. #25237

    • 添加了用于启用/禁用拼写检查器的 API。#26276

      ¥Added APIs to enable/disable spell checker. #26276

  • shell API 变更:

    ¥shell API changes:

    • 添加了新的异步 shell.trashItem() API,以取代同步 shell.moveItemToTrash()#25114

      ¥Added a new asynchronous shell.trashItem() API, replacing the synchronous shell.moveItemToTrash(). #25114

  • webContents API 变更:

    ¥webContents API changes:

    • 在控制台中添加了一个小型控制台提示,以帮助调试渲染器崩溃。#25317

      ¥Added a small console hint to console to help debug renderer crashes. #25317

    • 在 webRequest 处理程序的 detail 对象中添加了 framewebContents 属性。#27334

      ¥Added frame and webContents properties to the details object in webRequest handlers. #27334

    • 添加 webContents.forcefullyCrashRenderer() 以强制终止渲染器进程,以帮助恢复挂起的渲染器。#25580

      ¥Added webContents.forcefullyCrashRenderer() to forcefully terminate a renderer process to assist with recovering a hung renderer. #25580

    • 为渲染器创建的子窗口添加了 setWindowOpenHandler API,并弃用了 new-window 事件。#24517

      ¥Added setWindowOpenHandler API for renderer-created child windows, and deprecate new-window event. #24517

  • webFrame API 变更:

    ¥webFrame API changes:

    • 为渲染器添加了拼写检查 API。#25060

      ¥Added spellcheck API to renderer. #25060

移除/弃用的变更

¥Removed/Deprecated Changes

以下 API 已被删除或弃用:

¥The following APIs have been removed or are now deprecated:

  • 弃用 remote 模块。已被 @electron/remote 取代。#25293

    ¥Deprecated the remote module. It is replaced by @electron/remote. #25293

  • 移除已弃用的 crashReporter API。#26709

    ¥Removed deprecated crashReporter APIs. #26709

  • 从打包应用中的默认 '帮助' 菜单中移除了指向 Electron 网站的链接。#25831

    ¥Removed links to the Electron website from the default 'Help' menu in packaged apps. #25831

9.x.y 停止支持

¥End of Support for 9.x.y

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

¥Electron 9.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 的新主要版本及其组件的新版本。暂定 13.0.0 计划 列出了 Electron 13.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 13.0.0 schedule maps out key dates in the Electron 13.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.