跳到主要内容

Electron 28.0.0

·阅读时长 3 分钟

Electron 28.0.0 已发布!它包含对 Chromium 120.0.6099.56、V8 12.0 和 Node.js 18.18.2 的升级。


Electron 团队很高兴地宣布 Electron 28.0.0 版本发布!您可以通过 npm 安装它,使用命令 npm install electron@latest,或从我们的发布网站下载。请继续阅读以了解此版本的详细信息。

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

值得注意的更改

亮点

  • 实现了对 ECMAScript 模块或 ESM 的支持(什么是 ECMAScript 模块?在此了解更多)。这包括对 Electron 本身中的 ESM 支持,以及 UtilityProcess API 入口点等领域。请参阅我们的 ESM 文档了解更多详细信息。
  • 除了在 Electron 本身中启用 ESM 支持外,Electron Forge 也支持使用 ESM 来打包、构建和开发 Electron 应用。您可以在Forge v7.0.0 或更高版本中找到此支持。

技术栈更新

新特性

  • 启用 ESM 支持。#37535
  • UtilityProcess API 添加了 ESM 入口点。#40047
  • display 对象添加了多个属性,包括 detectedmaximumCursorSizenativeOrigin#40554
  • 添加了对 Linux 上 ELECTRON_OZONE_PLATFORM_HINT 环境变量的支持。#39792

重大更改

行为变更:将 WebContents.backgroundThrottling 设置为 false 会影响宿主 BrowserWindow 中的所有 WebContents

WebContents.backgroundThrottling 设置为 false 将禁用 BrowserWindow 中显示的所有 WebContents 的帧节流。

移除:BrowserWindow.setTrafficLightPosition(position)

BrowserWindow.setTrafficLightPosition(position) 已被移除,应改用 BrowserWindow.setWindowButtonPosition(position) API,该 API 接受 null 而不是 { x: 0, y: 0 } 来将位置重置为系统默认值。

// Removed in Electron 28
win.setTrafficLightPosition({ x: 10, y: 10 });
win.setTrafficLightPosition({ x: 0, y: 0 });

// Replace with
win.setWindowButtonPosition({ x: 10, y: 10 });
win.setWindowButtonPosition(null);

移除:BrowserWindow.getTrafficLightPosition()

BrowserWindow.getTrafficLightPosition() 已被移除,应改用 BrowserWindow.getWindowButtonPosition() API,该 API 在没有自定义位置时返回 null 而不是 { x: 0, y: 0 }

// Removed in Electron 28
const pos = win.getTrafficLightPosition();
if (pos.x === 0 && pos.y === 0) {
// No custom position.
}

// Replace with
const ret = win.getWindowButtonPosition();
if (ret === null) {
// No custom position.
}

移除:ipcRenderer.sendTo()

ipcRenderer.sendTo() API 已被移除。应通过在渲染器之间设置MessageChannel 来替代。

IpcRendererEventsenderIdsenderIsMainFrame 属性也已被移除。

移除:app.runningUnderRosettaTranslation

app.runningUnderRosettaTranslation 属性已被移除。请改用 app.runningUnderARM64Translation

// Removed
console.log(app.runningUnderRosettaTranslation);
// Replace with
console.log(app.runningUnderARM64Translation);

结束对 25.x.y 的支持

根据项目的支持策略,Electron 25.x.y 已达到支持结束日期。鼓励开发者和应用升级到更新的 Electron 版本。

E28 (23年12月)E29 (24年2月)E30 (24年4月)
28.x.y29.x.y30.x.y
27.x.y28.x.y29.x.y
26.x.y27.x.y28.x.y

接下来

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

您可以在此处找到 Electron 的公开时间表

有关未来更改的更多信息,请参阅计划中的重大更改页面。