Electron 32.0.0
Electron 32.0.0 已发布! 此版本包含了对 Chromium 128.0.6613.36、V8 12.8 和 Node 20.16.0 的升级。
Electron 团队很高兴地宣布 Electron 32.0.0 发布!您可以通过 npm install electron@latest 使用 npm 安装,或从我们的发布网站下载。请继续阅读以获取此版本的详细信息。
如果您有任何反馈,请在 Twitter 或 Mastodon 上与我们分享,或者加入我们的社区 Discord!Bug 和功能请求可以在 Electron 的问题追踪器中报告。
重要变更
亮点
- 在我们的文档中新增了 API 版本历史,这项功能由 @piotrpdev 作为 Google Summer of Code 的一部分创建。您可以在这篇博文中了解更多信息。 #42982
- 从 Web File API 中移除了非标准的 File.path 扩展。#42053
- 当尝试在被阻止的路径中打开文件或目录时,Web 文件系统 API 中的失败路径已与上游保持一致。 #42993
- 将以下现有导航相关 API 添加到
webcontents.navigationHistory:canGoBack、goBack、canGoForward、goForward、canGoToOffset、goToOffset、clear。以前的导航 API 现已弃用。#41752
技术栈变更
- Chromium
128.0.6613.36 - Node
20.16.0 - V8
12.8
Electron 32 将 Chromium 从 126.0.6478.36 升级到 128.0.6613.36,Node 从 20.14.0 升级到 20.16.0,V8 从 12.6 升级到 12.8。
新特性
- 增加了对通过
app模块的'login'事件响应从实用进程发起的认证请求的支持。#43317 - 将
cumulativeCPUUsage属性添加到CPUUsage结构中,该属性返回自进程启动以来使用的 CPU 时间总秒数。#41819 - 将以下现有导航相关 API 添加到
webContents.navigationHistory:canGoBack、goBack、canGoForward、goForward、canGoToOffset、goToOffset、clear。#41752 - 扩展了
WebContentsView以接受预先存在的webContents对象。#42086 - 向
nativeTheme添加了一个新属性prefersReducedTransparency,它指示用户是否已通过系统辅助功能设置选择降低操作系统级别的透明度。#43137 - 在文件系统访问 API 中,当尝试打开被阻止路径中的文件或目录时,其失败路径与上游保持一致。#42993
- 在 Linux 上启用了 Windows 控件覆盖 API。#42681
- 在网络请求中启用了
zstd压缩。#43300
破坏性变更
已移除:File.path
Web File 对象的非标准 path 属性是在 Electron 的早期版本中添加的,作为在渲染器中进行所有操作更常见时处理本地文件的便捷方法。然而,它代表了对标准的偏离,也带来了一个轻微的安全风险,因此从 Electron 32.0 开始,它已被移除,取而代之的是 webUtils.getPathForFile 方法。
// 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 上的 clearHistory、canGoBack、goBack、canGoForward、goForward、goToIndex、canGoToOffset、goToOffset
WebContents 实例上的导航相关 API 现已弃用。这些 API 已移至 WebContents 的 navigationHistory 属性,以提供更结构化和直观的界面来管理导航历史记录。
// 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 目录将被删除
如果您在 app.getPath('userData') 返回的目录中有一个名为 databases 的目录,它将在 Electron 32 首次运行时被删除。databases 目录曾被 WebSQL 使用,该功能已在 Electron 31 中移除。Chromium 现在执行一项清理操作,会删除此目录。请参阅问题 #45396。
终止对 29.x.y 的支持
根据项目的支持策略,Electron 29.x.y 已达到支持结束阶段。建议开发人员和应用程序升级到更新的 Electron 版本。
| E32 (24年8月) | E33 (24年10月) | E34 (25年1月) |
|---|---|---|
| 32.x.y | 33.x.y | 34.x.y |
| 31.x.y | 32.x.y | 33.x.y |
| 30.x.y | 31.x.y | 32.x.y |
下一步计划
短期内,您可以预期团队将继续专注于跟进构成 Electron 的主要组件(包括 Chromium、Node 和 V8)的开发。
您可以在此处找到 Electron 的公开时间线。
有关未来变更的更多信息,请参阅计划中的破坏性变更页面。
