跳到主要內容

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 的 issue tracker 中回報。

重大變更

重點

  • 實作了對 ECMAScript 模組或 ESM 的支援 (什麼是 ECMAScript 模組? 在此處了解更多資訊。這包括對 Electron 本身以及 UtilityProcess API 進入點等區域的 ESM 支援。請參閱我們的 ESM 文件 以取得更多詳細資訊。
  • 除了在 Electron 本身中啟用 ESM 支援外,Electron Forge 也支援使用 ESM 來封裝、建置和開發 Electron 應用程式。您可以在 Forge v7.0.0 或更高版本中找到此支援。

堆疊變更

新功能

  • 已啟用 ESM 支援。#37535
    • 如需更多詳細資訊,請參閱 ESM 文件
  • 將 ESM 進入點新增至 UtilityProcess API。#40047
  • 將多個屬性新增至 display 物件,包括 detectedmaximumCursorSizenativeOrigin#40554
  • 在 Linux 上新增對 ELECTRON_OZONE_PLATFORM_HINT 環境變數的支援。#39792

重大變更

行為已變更:設定為 false 的 WebContents.backgroundThrottling 會影響主機 BrowserWindow 中的所有 WebContents

設定為 false 的 WebContents.backgroundThrottling 將停用 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 (2023 年 12 月)E29 (2024 年 2 月)E30 (2024 年 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 的公開時程表

有關未來變更的更多資訊,請參閱計畫的重大變更頁面。