跳到主要内容

Electron 32.0.0

·4 分钟阅读

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 安装它,或者从我们的发行版本网站下载它。继续阅读以了解有关此版本的详细信息。

如果您有任何反馈,请在 TwitterMastodon 上与我们分享,或加入我们的社区 Discord!错误和功能请求可以在 Electron 的 issue 跟踪器中报告。

值得注意的更改

亮点

  • 在我们的文档中添加了新的 API 版本历史记录,这是 @piotrpdev 作为 Google 编程之夏的一部分创建的功能。您可以在这篇博文中了解更多信息。#42982
  • 从 Web File API 中删除了非标准的 File.path 扩展。#42053
  • 当尝试在阻止的路径中打开文件或目录时,使 Web File System API 中的失败路径与上游对齐。#42993
  • 将以下现有的导航相关 API 添加到 webcontents.navigationHistorycanGoBackgoBackcanGoForwardgoForwardcanGoToOffsetgoToOffsetclear。之前的导航 API 现在已被弃用。#41752

堆栈更改

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.navigationHistorycanGoBackgoBackcanGoForwardgoForwardcanGoToOffsetgoToOffsetclear#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 上的 clearHistorycanGoBackgoBackcanGoForwardgoForwardgoToIndexcanGoToOffsetgoToOffset

WebContents 实例上的导航相关 API 现在已弃用。这些 API 已移至 WebContentsnavigationHistory 属性,以便为管理导航历史记录提供更结构化和直观的界面。

// 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.y33.x.y34.x.y
31.x.y32.x.y33.x.y
30.x.y31.x.y32.x.y

下一步

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

您可以在此处找到 Electron 的公共时间线

有关未来更改的更多信息,请访问计划的破坏性更改页面。