Electron 32.0.0

417 阅读3分钟

作者: VerteDinde

译者: ylduang

Electron 32.0.0 已发布!包括升级 Chromium 128.0.6613.36,和 V8 12.8 以及 Node.js 20.16.2


Electron 团队很高兴发布了 Electron 32.0.0!你可以通过 npm install electron@latest 或者从我们的发布网站下载它。继续阅读此版本的详细信息。

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

重要变化

重点内容

  • 在我们的文档中添加新的 API 版本历史,一个由 @piotrpdev 创建的功能,作为 Google Summer 代码的一部分。#42982
  • 从 Web 文件 API 中移除非标准 File.path 扩展。#42053
  • 尝试打开受阻止路径中的文件或目录时,将 Web File System API 中的故障路径与上游对齐。#42993
  • 将以下现有的导航相关 API 添加到 webContents.navigationHistory : canGoBack, goBack, canGoForward, goForward, canGoToOffset, goToOffset, clear。旧的导航 API 现已被废弃。#41752

架构(Stack)更新

Electron 32 将 Chromium 从 126.0.6478.36 升级到 128.0.6613.36, Node 从 20.14.0 升级到 20.16.1 以及 V8 从 12.6 升级到 12.8

新特性

  • 添加了对通过 app 模块的 'login' 事件,响应来自实用程序进程发起的认证请求的支持。#43317
  • CPUUsage 结构中添加了 cumulativeCPUUsage 属性,该属性返回自进程启动以来使用的 CPU 时间的总秒数。#41819
  • 将以下现有的导航相关 API 添加到 webContents.navigationHistory: canGoBackgoBackcanGoForwardgoForwardcanGoToOffsetgoToOffsetclear#41752
  • 扩展 WebContentsView 以接受预先存在的 webContents 对象。#42086
  • nativeTheme 中添加了一个新属性 prefersReducedTransparency,该属性指示用户是否选择通过系统辅助功能设置来降低操作系统级别的透明度。#43137
  • 尝试打开阻塞路径中的文件或目录时,将文件系统访问 API 中的故障路径与上游对齐。#42993
  • 在 Linux 上启用 Windows 控制叠加层 API。#42681
  • 在网络请求中启用 zstd 压缩。#43300

重大更改

移除: File.path

Electron 的早期版本在 Web File 对象中添加了非标准 path 属性作为在渲染器中执行所有操作更为常见时处理本机文件的便捷方法。然而它偏离了标准,并且也带来了较小的安全风险,因此从 Electron 32 开始它已被移除,取而代之的是 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 已被移动到 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);

终止对 29.x.y 的支持

根据项目的支持政策,Electron 29.x.y 已经达到了支持的终点。我们鼓励开发者将应用程序升级到更新的 Electron 版本。

E26(24 年 8月)E33 (24 年 10 月)E28 (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 的公开时间表

有关这些和未来变化的更多信息可在计划的突破性变化页面找到。

原文: Electron 32.0.0

Electron China 社区