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 作为 Google 编程之夏项目的一部分而创建的。您可以在此博客文章中了解更多信息。 #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 Control Overlay 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 (2024 年 8 月) | E33 (2024 年 10 月) | E34 (2025 年 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 的公开时间线。
有关未来变更的更多信息,请参阅“计划中的重大变更”页面。