Skip to main content

Electron 32.0.0

· 7 min read

Electron 32.0.0 已发布!它包含对 Chromium 128.0.6613.36、V8 12.8 和 Node 20.16.0 的升级。

🌐 Electron 32.0.0 has been released! It includes upgrades to Chromium 128.0.6613.36, V8 12.8, and Node 20.16.0.


Electron 团队很高兴地宣布发布 Electron 32.0.0!你可以通过 npm 使用 npm install electron@latest 安装,或从我们的发布网站下载。请继续阅读以了解此次发布的详细信息。

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

如果你有任何反馈,请通过 TwitterMastodon 与我们分享,或者加入我们的社区 Discord!错误和功能请求可以在 Electron 的 问题追踪器 中报告。

🌐 If you have any feedback, please share it with us on Twitter or Mastodon, or join our community Discord! Bugs and feature requests can be reported in Electron's issue tracker.

显著变化

🌐 Notable Changes

  • 在我们的文档中新增了 API 版本历史记录,这是由 @piotrpdev 在 Google Summer of Code 项目中创建的功能。你可以在这篇博文中了解更多信息。#42982
  • 已从 Web 文件 API 中移除非标准的 File.path 扩展。 #42053
  • 在尝试打开被阻止路径中的文件或目录时,将 Web 文件系统 API 中的失败路径与上游对齐。#42993
  • 已将以下现有的与导航相关的 API 添加到 webcontents.navigationHistorycanGoBackgoBackcanGoForwardgoForwardcanGoToOffsetgoToOffsetclear。之前的导航 API 已被弃用。#41752

技术栈变更

🌐 Stack Changes

Electron 32 将 Chromium 从 126.0.6478.36 升级到 128.0.6613.36,Node 从 20.14.0 升级到 20.16.0,V8 从 12.6 升级到 12.8

🌐 Electron 32 upgrades Chromium from 126.0.6478.36 to 128.0.6613.36, Node from 20.14.0 to 20.16.0, and V8 from 12.6 to 12.8.

新功能

🌐 New Features

  • 添加了通过 app 模块的 'login' 事件响应由实用程序进程发起的认证请求的支持。#43317
  • CPUUsage 结构添加了 cumulativeCPUUsage 属性,该属性返回自进程启动以来使用的 CPU 时间总秒数。#41819
  • 已将以下现有导航相关 API 添加到 webContents.navigationHistorycanGoBackgoBackcanGoForwardgoForwardcanGoToOffsetgoToOffsetclear#41752
  • 扩展 WebContentsView 以接受预先存在的 webContents 对象。 #42086
  • nativeTheme 中添加了一个新属性 prefersReducedTransparency,用于指示用户是否通过系统辅助功能设置选择了降低操作系统级别的透明度。#43137
  • 在尝试打开被阻止路径中的文件或目录时,使文件系统访问 API 的失败路径与上游保持一致。#42993
  • 在 Linux 上启用了 Windows 控制覆盖 API。#42681
  • 在网络请求中启用了 zstd 压缩。 #43300

重大变化

🌐 Breaking Changes

已移除:File.path

🌐 Removed: File.path

Web File 对象的非标准 path 属性是在早期版本的 Electron 中添加的,作为在渲染器中操作本地文件时的一种便利方法。然而,它偏离了标准,并且也存在一定的安全风险,因此从 Electron 32.0 开始,它已被移除,转而使用 webUtils.getPathForFile 方法。

🌐 The nonstandard path property of the Web File object was added in an early version of Electron as a convenience method for working with native files when doing everything in the renderer was more common. However, it represents a deviation from the standard and poses a minor security risk as well, so beginning in Electron 32.0 it has been removed in favor of the webUtils.getPathForFile method.

// Before (renderer)
const file = document.querySelector('input[type=file]');
alert(`Uploaded file path was: ${file.path}`);
// After (renderer)
const file = document.querySelector('input[type=file]');
electron.showFilePath(file);

// After (preload)
const { contextBridge, webUtils } = require('electron');

contextBridge.exposeInMainWorld('electron', {
showFilePath(file) {
// It's best not to expose the full file path to the web content if
// possible.
const path = webUtils.getPathForFile(file);
alert(`Uploaded file path was: ${path}`);
},
});

已弃用:clearHistorycanGoBackgoBackcanGoForwardgoForwardgoToIndexcanGoToOffsetgoToOffsetWebContents

🌐 Deprecated: clearHistory, canGoBack, goBack, canGoForward, goForward, goToIndex, canGoToOffset, goToOffset on WebContents

WebContents 实例上的导航相关 API 已不再推荐使用。这些 API 已迁移到 WebContentsnavigationHistory 属性中,以提供更结构化和直观的导航历史管理接口。

🌐 Navigation-related APIs on WebContents instances are now deprecated. These APIs have been moved to the navigationHistory property of WebContents to provide a more structured and intuitive interface for managing navigation history.

// Deprecated
win.webContents.clearHistory();
win.webContents.canGoBack();
win.webContents.goBack();
win.webContents.canGoForward();
win.webContents.goForward();
win.webContents.goToIndex(index);
win.webContents.canGoToOffset();
win.webContents.goToOffset(index);

// Replace with
win.webContents.navigationHistory.clear();
win.webContents.navigationHistory.canGoBack();
win.webContents.navigationHistory.goBack();
win.webContents.navigationHistory.canGoForward();
win.webContents.navigationHistory.goForward();
win.webContents.navigationHistory.canGoToOffset();
win.webContents.navigationHistory.goToOffset(index);

行为已更改:userData 中的目录 databases 将被删除

🌐 Behavior changed: Directory databases in userData will be deleted

如果在 app.getPath('userData') 返回的目录中有一个名为 databases 的目录,当 Electron 32 首次运行时,该目录将被删除。databases 目录曾被 WebSQL 使用,而 WebSQL 已在 Electron 31 中被移除。Chromium 现在会执行清理操作,删除该目录。请参见 issue #45396

🌐 If you have a directory called databases in the directory returned by app.getPath('userData'), it will be deleted when Electron 32 is first run. The databases directory was used by WebSQL, which was removed in Electron 31. Chromium now performs a cleanup that deletes this directory. See issue #45396.

29.x.y 支持终止

🌐 End of Support for 29.x.y

根据项目的支持政策,Electron 29.x.y 已结束支持。我们鼓励开发者和应用升级到更新的 Electron 版本。

🌐 Electron 29.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.

E32(2024年8月)E33(2024年10月)E34(2025年1月)
32.x.y33.x.y34.x.y
31.x.y32.x.y33.x.y
30.x.y31.x.y32.x.y

下一步计划

🌐 What's Next

短期内,你可以预期团队将继续专注于跟上构成 Electron 的主要组件(包括 Chromium、Node 和 V8)的开发。

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

你可以在这里找到 Electron 的公开时间线

🌐 You can find Electron's public timeline here.

有关未来更改的更多信息可以在计划中的重大变更页面上找到。

🌐 More information about future changes can be found on the Planned Breaking Changes page.