Skip to main content

Electron 12.0.0

· 9 min read

Electron 12.0.0 已发布!它包括对 Chromium 89、V8 8.9 和 Node.js 14.16 的升级。我们对远程模块进行了修改,新增了 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 使用 npm install electron@latest 安装,或从我们的发布网站下载。继续阅读以了解此版本的详细信息,并请分享你的任何反馈!

🌐 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!

技术栈变更

🌐 Stack Changes

显著变化

🌐 Notable Changes

  • ContextBridge exposeInMainWorld 方法现在可以暴露非对象 API。#26834
  • 已从 Node 12 升级到 Node 14。 #23249
  • 新增了一个 webFrameMain API,用于从主进程访问 WebContents 实例的子帧。#25464
  • contextIsolationworldSafeExecuteJavaScript 的默认值现在是 true#27949 #27502

请查看 12.0.0 版本说明 以获取新功能和更改的完整列表。

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

重大变化

🌐 Breaking Changes

  • 已弃用 remote 模块。它已被 @electron/remote 替代。#25293
  • contextIsolation 的默认值更改为 true#27949
  • worldSafeExecuteJavaScript 的默认值更改为 true#27502
  • crashReporter.start({ compress }) 的默认值从 false 改为 true#25288
  • 移除了 Flash 支持:Chromium 已经移除了对 Flash 的支持,Electron 12 中也已移除。有关更多详细信息,请参见 Chromium 的 Flash 路线图
  • Chrome 在 x86 上需要 SSE3:Chromium 已经不再支持不满足 SSE3(流式 SIMD 扩展 3)最低要求的旧 x86 CPU。相关支持已被移除。Electron 12 中也移除了此支持。

有关这些和未来更改的更多信息,请参阅计划中的重大更改页面。

🌐 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 的更多信息,请参见 这里 和我们的 文档
  • app API 变更:
    • 已将非本地化的 serviceName 添加到 'child-process-gone' / app.getAppMetrics()#25975
    • 新增了 app.runningUnderRosettaTranslation 属性,用于检测在 Apple Silicon 上运行时是否处于 Rosetta 模式。#26444
    • 已将 exitCode 添加到 render-process-gone 详情(应用和网页内容)。#27677
  • BrowserWindow API 变更:
    • 新增了 BrowserWindow.isTabletMode() API。 #25209
    • 已向 BrowserWindow 添加 resized(Windows/macOS)和 moved(Windows)事件。#26216
    • 新增了 system-context-menu 事件,以允许阻止和覆盖系统上下文菜单。 #25795
    • 添加了 win.setTopBrowserView(),以便可以提高 BrowserView#27713
    • 添加了 webPreferences.preferredSizeMode,以允许根据文档的最小尺寸调整视图大小。#25874
  • contextBridge API 变更:
    • 允许 ContextBridge exposeInMainWorld 方法暴露非对象的 API。 #26834
  • display API 变更:
    • Display 对象中添加了 displayFrequency 属性,以便获取 Windows 上的刷新率信息。#26472
  • extensions API 变更:
    • 已添加对一些 chrome.management API 的支持。 #25098
  • MenuItem API 变更:
    • 新增支持显示 macOS 共享菜单。 #25629
  • net API 变更:
    • net.request() 添加了一个新的 credentials 选项。#25284
    • 已添加 net.online 用于检测当前是否有互联网连接。 #21004
  • powerMonitor API 变更:
    • 已添加 powerMonitor.onBatteryPower#26494
    • 在 macOS 上将快速用户切换事件添加到 powerMonitor。#25321
  • session API 变更:
    • ses.loadExtension() API 中添加了 allowFileAccess 选项。#27702
    • session.setPermissionRequestHandler 添加了 display-capture API。 #27696
    • session.setSSLConfig 中添加了 disabledCipherSuites 选项。 #25818
    • 已向 session 添加 extension-loadedextension-unloadedextension-ready 事件。 #25385
    • 添加了 session.setSSLConfig() 以允许配置 SSL。 #25461
    • 添加了在 session.setProxy() 中显式指定 directauto_detectsystem 模式的支持。#24937
    • 添加了 串行 API 支持。 #25237
    • 添加了用于启用/禁用拼写检查器的 API。 #26276
  • shell API 变更:
    • 新增了一个异步 shell.trashItem() API,取代了同步 shell.moveItemToTrash()#25114
  • webContents API 变更:
    • 在控制台中添加了一个小提示,以帮助调试渲染器崩溃。 #25317
    • 在 webRequest 处理程序的 details 对象中添加了 framewebContents 属性。#27334
    • 添加了 webContents.forcefullyCrashRenderer() 用于强制终止渲染器进程,以帮助恢复卡住的渲染器。#25580
    • 为渲染器创建的子窗口添加了 setWindowOpenHandler API,并弃用 new-window 事件。 #24517
  • webFrame API 变更:
    • 在渲染器中添加了拼写检查 API。#25060

移除/弃用的变更

🌐 Removed/Deprecated Changes

以下 API 已被删除或弃用:

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

  • 已弃用 remote 模块。它已被 @electron/remote 替代。#25293
  • 已移除不推荐使用的 crashReporter API。#26709
  • 从打包应用的默认“帮助”菜单中移除了指向 Electron 网站的链接。#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.