跳转到主要内容

Electron 27.0.0

·阅读时长 4 分钟

Electron 27.0.0 现已发布! 它包括对 Chromium 118.0.5993.32、V8 11.8 和 Node.js 18.17.1 的升级。


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

如果您有任何反馈,请在 TwitterMastodon 上与我们分享,或者加入我们的社区 Discord! 欢迎在 Electron 的 issue tracker 中报告 Bug 和功能请求。

重要变更

技术栈变更

破坏性变更

已移除:对 macOS 10.13 / 10.14 的支持

Chromium 不再支持 macOS 10.13 (High Sierra) 和 macOS 10.14 (Mojave)。

旧版本的 Electron 将继续在这些操作系统上运行,但运行 Electron v27.0.0 及更高版本将需要 macOS 10.15 (Catalina) 或更高版本。

已弃用:ipcRenderer.sendTo()

ipcRenderer.sendTo() API 已被弃用。 它应该被替换为在渲染器之间建立一个MessageChannel

IpcRendererEventsenderIdsenderIsMainFrame 属性也已被弃用。

已移除:systemPreferences 中的 color scheme 事件

以下 systemPreferences 事件已被移除:

  • inverted-color-scheme-changed
  • high-contrast-color-scheme-changed

请改用 nativeTheme 模块上新的 updated 事件。

// Removed
systemPreferences.on('inverted-color-scheme-changed', () => {
/* ... */
});
systemPreferences.on('high-contrast-color-scheme-changed', () => {
/* ... */
});

// Replace with
nativeTheme.on('updated', () => {
/* ... */
});

已移除:webContents.getPrinters

webContents.getPrinters 方法已被移除。 请改用 webContents.getPrintersAsync

const w = new BrowserWindow({ show: false });

// Removed
console.log(w.webContents.getPrinters());
// Replace with
w.webContents.getPrintersAsync().then((printers) => {
console.log(printers);
});

已移除:systemPreferences.{get,set}AppLevelAppearancesystemPreferences.appLevelAppearance

systemPreferences.getAppLevelAppearancesystemPreferences.setAppLevelAppearance 方法以及 systemPreferences.appLevelAppearance 属性已被移除。 请改用 nativeTheme 模块。

// Removed
systemPreferences.getAppLevelAppearance();
// Replace with
nativeTheme.shouldUseDarkColors;

// Removed
systemPreferences.appLevelAppearance;
// Replace with
nativeTheme.shouldUseDarkColors;

// Removed
systemPreferences.setAppLevelAppearance('dark');
// Replace with
nativeTheme.themeSource = 'dark';

已移除:systemPreferences.getColoralternate-selected-control-text

systemPreferences.getColoralternate-selected-control-text 值已被移除。 请改用 selected-content-background

// Removed
systemPreferences.getColor('alternate-selected-control-text');
// Replace with
systemPreferences.getColor('selected-content-background');

新特性

  • 添加了应用无障碍透明度设置 API #39631
  • 添加了对 chrome.scripting 扩展 API 的支持 #39675
  • 默认启用了 WaylandWindowDecorations #39644

终止对 24.x.y 的支持

根据项目的支持政策,Electron 24.x.y 已终止支持。 鼓励开发者和应用程序升级到较新版本的 Electron。

E27 (23年10月)E28 (23年12月)E29 (24年2月)
27.x.y28.x.y29.x.y
26.x.y27.x.y28.x.y
25.x.y26.x.y27.x.y

终止对 22.x.y 的扩展支持

今年早些时候,Electron 团队将 Electron 22 计划的生命周期结束日期从 2023 年 5 月 30 日延长至 2023 年 10 月 10 日,以配合 Chrome 对 Windows 7/8/8.1 的扩展支持(详情请见 告别 Windows 7/8/8.1)。

根据项目的支持政策和此支持扩展,Electron 22.x.y 已终止支持。 这将使支持回退到最新的三个稳定主版本,并将结束对 Windows 7/8/8.1 的官方支持。

下一步计划

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

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

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