跳转到主要内容

Electron 28.0.0

·阅读时长 4 分钟

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! Bug 和功能请求可以在 Electron 的 issue tracker 中报告。

重要变更

亮点

  • 实现了对 ECMAScript 模块或 ESM 的支持 (ECMAScript 模块是什么? 点击此处了解更多)。 这包括在 Electron 本身以及 UtilityProcess API 入口等领域对 ESM 的支持。 查看我们的 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,它接受 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,当没有自定义位置时,它会返回 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 的公开时间线

有关未来变更的更多信息,请参阅计划中的破坏性变更页面。