Skip to main content

Electron 32.0.0

· 9 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 install electron@latest 使用 npm 安装它,也可以从我们的 发布网站。继续阅读以了解有关此版本的详细信息。

¥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

亮点

¥Highlights

  • 在我们的文档中添加了新的 API 版本历史记录,这是 @piotrpdev 作为 Google Summer of Code 的一部分创建的功能。你可以在 这篇博文 中了解更多信息。#42982

    ¥Added new API version history in our documentation, a feature created by @piotrpdev as part of Google Summer of Code. You can learn more about it in this blog post. #42982

  • 从 Web File API 中移除了非标准的 File.path 扩展。#42053

    ¥Removed nonstandard File.path extension from the Web File API. #42053

  • 尝试打开被阻止路径中的文件或目录时,Web 文件系统 API 中的故障路径与上游保持一致。#42993

    ¥Aligned failure pathway in Web File System API with upstream when attempting to open a file or directory in a blocked path. #42993

  • webcontents.navigationHistory 中添加了以下现有的导航相关 API:canGoBack, goBack, canGoForward, goForward, canGoToOffset, goToOffset, clear.之前的导航 API 现已弃用。#41752

    ¥Added the following existing navigation-related APIs to webcontents.navigationHistory: canGoBack, goBack, canGoForward, goForward, canGoToOffset, goToOffset, clear. The previous navigation APIs are now deprecated. #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

    ¥Added support for responding to auth requests initiated from the utility process via the app module's 'login' event. #43317

  • CPUUsage 结构体中添加了 cumulativeCPUUsage 属性,该属性返回自进程启动以来 CPU 时间的总秒数。#41819

    ¥Added the cumulativeCPUUsage property to the CPUUsage structure, which returns the total seconds of CPU time used since process startup. #41819

  • webContents.navigationHistory 中添加了以下现有的导航相关 API:canGoBack, goBack, canGoForward, goForward, canGoToOffset, goToOffset, clear.#41752

    ¥Added the following existing navigation related APIs to webContents.navigationHistory: canGoBack, goBack, canGoForward, goForward, canGoToOffset, goToOffset, clear. #41752

  • 扩展 WebContentsView 以接受预先存在的 webContents 对象。#42086

    ¥Extended WebContentsView to accept pre-existing webContents objects. #42086

  • nativeTheme 中添加了新的属性 prefersReducedTransparency,用于指示用户是否已选择通过系统辅助功能设置降低操作系统级别的透明度。#43137

    ¥Added a new property prefersReducedTransparency to nativeTheme, which indicates whether the user has chosen to reduce OS-level transparency via system accessibility settings. #43137

  • 尝试打开被阻止路径中的文件或目录时,文件系统访问 API 中的故障路径与上游保持一致。#42993

    ¥Aligned failure pathway in File System Access API with upstream when attempting to open a file or directory in a blocked path. #42993

  • 在 Linux 上启用 Windows Control Overlay API。#42681

    ¥Enabled the Windows Control Overlay API on Linux. #42681

  • 在网络请求中启用 zstd 压缩。#43300

    ¥Enabled zstd compression in network requests. #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}`);
},
});

已弃用:WebContents 上的 clearHistorycanGoBackgoBackcanGoForwardgoForwardgoToIndexcanGoToOffsetgoToOffset

¥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 使用,该目录在 Electron 31 中被删除。Chromium 现在执行删除此目录的清理。参见 问题 #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.