查看原文
其他

Electron 28.0.0 正式发布

小懒 FED实验室 2024-02-12
关注下方公众号,获取更多热点资讯

Electron 28.0.0 版本已正式发布🎉,带来不少特性更新🌟,大家可以通过 npm i electron@latest 快速安装使用。亮点包括:

  • 增加对 ESM 的支持
  • Electron Forage 添加了对 ESM 支持
  • Chromium 更新至 120.0.6099.56
  • V8 引擎升级
  • 其他错误修复和改进

重要更改

Electron 28.0.0 版本实现了对 ECMAScript模块 或 ESM 的支持。这包括对 Electron 本身以及 UtilityProcess API 等的 ESM 支持。同时,Electron 团队还为 Electron Forge 添加了 ESM 支持!支持使用ESM来打包、构建和开发Electron应用程序,您可以在 Electron Forge 7.0.0 及更高版本中使用 ESM。

依赖升级

特性更新

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

重大变化

WebContents.backgroundThrottling 变化

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

移除 BrowserWindow.setTrafficLightPosition()

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

// 在 Electron 28 被移除
win.setTrafficLightPosition({ x10y10 });
win.setTrafficLightPosition({ x0y0 });

// 替换为
win.setWindowButtonPosition({ x10y10 });
win.setWindowButtonPosition(null);

移除 BrowserWindow.getTrafficLightPosition()

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

// 在Electron 28中被移除
const pos = win.getTrafficLightPosition();
if (pos.x === 0 && pos.y === 0) {
  // 没有自定义位置。
}

// 替换为
const ret = win.getWindowButtonPosition();
if (ret === null) {
  // 没有自定义位置。
}

移除 ipcRenderer.sendTo()

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

IpcRendererEventsenderIdsenderIsMainFrame 属性也已被删除。

移除:app.runningUnderRosettaTranslation

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

// 在 Electron 28 中被移除
console.log(app.runningUnderRosettaTranslation);
// 替换为
console.log(app.runningUnderARM64Translation);

结束对 25.x.y 版本支持

根据该项目的支持政策,Electron 25.x.y 已经达到支持结束的状态。开发人员和应用程序被鼓励升级到新版本的 Electron。

E28 (Dec'23)E29 (Feb'24)E30 (Apr'24)
28.x.y29.x.y30.x.y
27.x.y28.x.y29.x.y
26.x.y27.x.y28.x.y

未来计划

在短期内,Electron 团队会继续专注于 Electron 的主要组件(包括Chromium、Node 和 V8)的开发。Electron 经常在发布 Chromium 版本的同时发布重要版本,更多特性尽请期待。

附:主要版本时间线

ElectronAlphaBetaStableEOLChromeNodeSupported
29.0.02023-Dec-072023-Jan-242023-Feb-202024-Aug-20M122v18.19
28.0.02023-Oct-112023-Nov-062023-Dec-052024-Jun-11M120v18.18
27.0.02023-Aug-172023-Sep-132023-Oct-102024-Apr-16M118v18.17
26.0.02023-Jun-012023-Jun-272023-Aug-152024-Feb-20M116v18.16
25.0.02023-Apr-102023-May-022023-May-302023-Dec-05M114v18.15🚫
24.0.02023-Feb-092023-Mar-072023-Apr-042023-Oct-10M112v18.14🚫
23.0.02022-Dec-012023-Jan-102023-Feb-072023-Aug-15M110v18.12🚫
22.0.02022-Sep-292022-Oct-252022-Nov-292023-Oct-10M108v16.17🚫
21.0.02022-Aug-042022-Aug-302022-Sep-272023-Apr-04M106v16.16🚫
20.0.02022-May-262022-Jun-212022-Aug-022023-Feb-07M104v16.15🚫

大家都在看

继续滑动看下一个

Electron 28.0.0 正式发布

小懒 FED实验室
向上滑动看下一个

您可能也对以下帖子感兴趣

文章有问题?点此查看未经处理的缓存