跳到主要內容

Electron 29.0.0

·4 分鐘閱讀

Electron 29.0.0 已發布!它包含 Chromium 122.0.6261.39、V8 12.2 和 Node.js 20.9.0 的升級。


Electron 團隊很高興宣布 Electron 29.0.0 的發布!您可以使用 npm 透過 npm install electron@latest 安裝它,或從我們的版本網站下載。繼續閱讀以了解有關此版本的詳細資訊。

如果您有任何意見回饋,請在 TwitterMastodon 上與我們分享,或加入我們的社群 Discord!錯誤和功能請求可以在 Electron 的 問題追蹤器中回報。

重大變更

重點

  • 新增了新的頂層 webUtils 模組,這是一個渲染器進程模組,提供一個實用程式層來與 Web API 物件互動。模組中第一個可用的 API 是 webUtils.getPathForFile。Electron 先前的 File.path 擴增與 Web 標準有所偏差;這個新的 API 更符合目前的 Web 標準行為。

堆疊變更

Electron 29 將 Chromium 從 120.0.6099.56 升級到 122.0.6261.39,Node 從 18.18.2 升級到 20.9.0,以及 V8 從 12.0 升級到 12.2

新功能

  • 新增了新的 webUtils 模組,這是一個與 Web API 物件互動的實用程式層,以取代 File.path 擴增。#38776
  • 新增了 net 模組到公用程式進程#40890
  • 新增了新的 Electron 保險絲 grantFileProtocolExtraPrivileges,它使 file:// 協定選擇更安全且更具限制性的行為,以符合 Chromium。#40372
  • protocol.registerSchemesAsPrivileged 中新增了一個選項,允許在自訂協定中使用 V8 程式碼快取。#40544
  • 遷移了 app.{set|get}LoginItemSettings(settings) 以在 macOS 13.0+ 上使用 Apple 新建議的底層框架。#37244

重大變更

行為變更:ipcRenderer 無法再透過 contextBridge 傳送

嘗試透過 contextBridge 將整個 ipcRenderer 模組作為物件傳送,現在將導致橋接器的接收端出現空物件。此變更旨在移除/減輕安全漏洞。您不應透過橋接器直接公開 ipcRenderer 或其方法。而是提供如下所示的安全包裝器

contextBridge.exposeInMainWorld('app', {
onEvent: (cb) => ipcRenderer.on('foo', (e, ...args) => cb(args)),
});

已移除:app 上的 renderer-process-crashed 事件

已移除 app 上的 renderer-process-crashed 事件。請改用新的 render-process-gone 事件。

// Removed
app.on('renderer-process-crashed', (event, webContents, killed) => {
/* ... */
});

// Replace with
app.on('render-process-gone', (event, webContents, details) => {
/* ... */
});

已移除:WebContents<webview> 上的 crashed 事件

已移除 WebContents<webview> 上的 crashed 事件。請改用新的 render-process-gone 事件。

// Removed
win.webContents.on('crashed', (event, killed) => {
/* ... */
});
webview.addEventListener('crashed', (event) => {
/* ... */
});

// Replace with
win.webContents.on('render-process-gone', (event, details) => {
/* ... */
});
webview.addEventListener('render-process-gone', (event) => {
/* ... */
});

已移除:app 上的 gpu-process-crashed 事件

已移除 app 上的 gpu-process-crashed 事件。請改用新的 child-process-gone 事件。

// Removed
app.on('gpu-process-crashed', (event, killed) => {
/* ... */
});

// Replace with
app.on('child-process-gone', (event, details) => {
/* ... */
});

26.x.y 版本終止支援

根據專案的支援政策,Electron 26.x.y 已終止支援。建議開發人員和應用程式升級到較新版本的 Electron。

E29 (2 月 '24)E30 (4 月 '24)E31 (6 月 '24)
29.x.y30.x.y31.x.y
28.x.y29.x.y30.x.y
27.x.y28.x.y29.x.y

下一步

您是否知道 Electron 最近新增了社群意見徵求 (RFC) 流程?如果您想在框架中新增功能,RFC 可以作為與維護人員就其設計展開對話的有用工具。您也可以在 Pull Requests 中查看正在討論的即將到來的變更。若要了解更多資訊,請查看我們的electron/rfcs 介紹 部落格文章,或直接查看 electron/rfcs 儲存庫的 README。

在短期內,您可以預期團隊將繼續專注於跟上構成 Electron 的主要元件(包括 Chromium、Node 和 V8)的開發進度。

您可以在此處找到 Electron 的公開時程表。

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