• Electron 27.0.0 正式发布 快来看下有哪些更新吧!
  • 发布于 2个月前
  • 170 热度
    0 评论
10 月 10 日,Electron 27.0.0 正式发布!该版本包括了对 Chrome 118.0.5993.32、V8 11.8 和 Node.js 18.17.1 的升级。下面就来看看该版本都有哪些更新吧!

可以通过以下命令来安装最新版本:
npm install electron@latest

主要更新
技术栈
1. Chrome 118.0.5993.32
2. V8 11.8
3. Node.js 18.17.1

重要更新
移除:macOS 10.13 / 10.14 支持
Chromium 不再支持macOS 10.13(High Sierra)和macOS 10.14(Mojave)。旧版本的 Electron 仍然可以在这些操作系统上运行,但是需要 macOS 10.15(Catalina)或更高版本才能运行 Electron v27.0.0 及更高版本。

弃用:ipcRenderer.sendTo()
ipcRenderer.sendTo() API 已被弃用,应该被使用消息通道在渲染器之间来替代。IpcRendererEvent 的 senderId 和 senderIsMainFrame 属性也已被弃用。

移除:systemPreferences 中的颜色主题事件
该版本已移除以下 systemPreferences 事件:
inverted-color-scheme-changed
high-contrast-color-scheme-changed
改为使用 nativeTheme 模块中的新的 updated 事件:
// 堆代码 duidaima.com
// 移除
systemPreferences.on('inverted-color-scheme-changed', () => {
  /* ... */
});
systemPreferences.on('high-contrast-color-scheme-changed', () => {
  /* ... */
});

// 改为
nativeTheme.on('updated', () => {
  /* ... */
});
移除:webContents.getPrinters
该版本已移除 webContents.getPrinters 方法,改为使用 webContents.getPrintersAsync。
const w = new BrowserWindow({ show: false });

// 移除
console.log(w.webContents.getPrinters());
// 改为
w.webContents.getPrintersAsync().then((printers) => {
  console.log(printers);
});
移除:systemPreferences.{get,set}AppLevelAppearance 和 systemPreferences.appLevelAppearance
该版本已移除 systemPreferences.getAppLevelAppearance 和 systemPreferences.setAppLevelAppearance 方法,以及 systemPreferences.appLevelAppearance 属性。改为使用 nativeTheme 模块。
// 移除
systemPreferences.getAppLevelAppearance();
// 改为
nativeTheme.shouldUseDarkColors;

// 移除
systemPreferences.appLevelAppearance;
// 改为
nativeTheme.shouldUseDarkColors;

// 移除
systemPreferences.setAppLevelAppearance('dark');
// 改为
nativeTheme.themeSource = 'dark';
移除:systemPreferences.getColor 中的 alternate-selected-control-text 值
systemPreferences.getColor 中的 alternate-selected-control-text 值已被移除,改为使用 selected-content-background 值。
// 移除
systemPreferences.getColor('alternate-selected-control-text');
// 改为
systemPreferences.getColor('selected-content-background');
新功能
1.添加了应用程序辅助透明设置 API;
2.添加了对 chrome.scripting 扩展 API 的支持;
3.默认启用 WaylandWindowDecorations。

结束支持 24.x.y
根据项目的支持策略,Electron 24.x.y 已经到达了终止支持的阶段。鼓励开发者将应用升级到更高版本的 Electron。

结束对 22.x.y 的扩展支持
今年早些时候,为了与 Chrome 对 Windows 7/8/8.1 的扩展支持保持一致,Electron 团队将 Electron 22 的计划生命周期结束日期从 2023 年 5 月 30 日延长至 2023 年 10 月 10 日。

根据项目的支持政策和此支持扩展,Electron 22.x.y 已达到支持终止的阶段。这将将支持降级到最新的三个稳定主要版本,并结束对 Windows 7/8/8.1 的官方支持。
用户评论