跳至主要內容

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 FusegrantFileProtocolExtraPrivileges,它選擇讓 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 中看到正在討論的未來變更。若要瞭解更多資訊,請查看我們的「Introducing electron/rfcs」部落格文章,或直接查看 electron/rfcs 儲存庫的 README。

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

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

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