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 通过 npm install electron@latest 安装它,或从我们的 发布网站 下载它。继续阅读以了解此版本的详细信息。
如果您有任何反馈,请在 Twitter 或 Mastodon 上与我们分享,或加入我们的社区 Discord!错误和功能请求可以在 Electron 的 问题跟踪器 中报告。
值得注意的变化
- 添加了新的 API 版本历史记录到我们的文档中,此功能由 @piotrpdev 作为谷歌夏季实习生计划的一部分创建。您可以在 此博客文章 中了解更多信息。 #42982
- 移除了 Web File API 中非标准的 File.path 扩展。 #42053
- 将 Web File System 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 - 为
CPUUsage结构添加了cumulativeCPUUsage属性,该属性返回自进程启动以来的 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}`);
},
});
弃用: clearHistory、canGoBack、goBack、canGoForward、goForward、goToIndex、canGoToOffset、goToOffset 在 WebContents 上
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 使用,WebSQL 已在 Electron 31 中移除。 Chromium 现在执行清理操作,删除此目录。 请参阅 issue #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 的公共时间线。
有关未来变更的更多信息,请参见 计划中的破坏性变更 页面。
