跳转到主内容

43 篇博文 含有标签「发行版」

查看所有标签

Electron 35.0.0

· 阅读时间:约 8 分钟

Electron 35.0.0 已发布! 它包括对 Chromium 134.0.6998.44、V8 13.5 和 Node 22.14.0 的升级。


Electron 团队很高兴发布了 Electron 35.0.0 ! 你可以通过 npm install electron@latest 或者从我们的发布网站下载它。 继续阅读此版本的详细信息。

如果您有任何反馈,请在 BlueskyMastodon 上与我们分享,或加入我们的 Discord 社区! Bug 和功能请求可以在 Electron 的问题跟踪器中报告。

重要变化

用于改进扩展支持的 Service Worker 预加载脚本

最初由 @samuelmaddockRFC #8 中提出,Electron 35 添加了将预加载脚本附加到 Service Workers 的功能。 由于 Chrome 的 Manifest V3 Extensions 通过 扩展 service workers 处理大量工作,该功能填补了 Electron 对现代 Chrome 扩展程序支持的空白。

在会话级别以编程方式注册预加载脚本时,现在可以使用 ses.registerPreloadScript(script) API 将其专门应用于 Service Worker 上下文。

Main Process
// 将我们的预加载脚本添加到会话中。
session.defaultSession.registerPreloadScript({
// 我们的脚本应该只在 service worker 预加载中运行。
type: 'service-worker',
// 脚本的绝对路径。
script: path.join(__dirname, 'extension-sw-preload.js'),
});

此外,现在可以通过 ServiceWorkerMain.ipc 类在 Service Workers 及其附加的预加载脚本之间进行 IPC 通信。 预加载脚本仍将使用 ipcRenderer 模块与其 Service Worker 进行通信。 请参阅原始 RFC 以了解更多详细信息。

此功能之前已经进行了许多其他更改,为其奠定了基础:

  • #45329 重新设计了 Session 模块的预加载 API,以支持注册和取消注册单独的预加载脚本。
  • #45229 添加了实验性的 contextBridge.executeInMainWorld(executionScript) 脚本,用于通过 context bridge 在 main world 中执行 JavaScript。
  • #45341 添加了 ServiceWorkerMain 类,用于与主进程中的 Service Workers 交互。

架构(Stack)更新

Electron 35 将 Chromium 从 132.0.6834.83 升级到 134.0.6998.44,Node 从 20.18.1 升级到 22.14.0,V8 从 13.2 升级到 13.5

新特性

  • 在 Info.plist 中添加了 NSPrefersDisplaySafeAreaCompatibilityMode = false,以移除应用选项中的 “Scale to fit below built-in camera” 选项。 #45357 (也适用于 v34.1.0
  • 在主进程中添加了 ServiceWorkerMain 类,用于与服务工作线程进行交互。 #45341
    • ServiceWorkers 上添加了 running-status-changed 事件,用于指示服务工作线程的运行状态何时发生更改。
    • ServiceWorkers 上添加了 startWorkerForScope 方法,用于启动可能先前已停止的工作线程。
  • 添加了实验性的 contextBridge.executeInMainWorld 方法,用于安全地跨 world 边界执行代码。 #45330
  • 'console-message' 事件中添加了 frame 属性。 #43617
  • 在 Windows 上添加了 query-session-end 事件并改进了 session-end 事件。 #44598
  • 添加 view.getVisible()#45409
  • 添加了 webContents.navigationHistory.restore(index, entries) API,允许恢复导航记录。 #45583
  • BrowserWindow.setVibrancy 中添加了可选的动画参数。 #35987
  • document.executeCommand("paste") 添加了权限支持。 #45471 (同样在 v34.1.0 中)
  • 在 Windows 上添加了对 roundedCorners BrowserWindow 构造函数选项的支持。 #45740 (同样在 v34.3.0 中)
  • 添加了对 service worker 线程预加载脚本的支持。 #45408
  • 支持 Portal 的 globalShortcuts。 Electron 必须使用 --enable-features=GlobalShortcutsPortal 运行,该功能才能生效。 #45297

重大更改

移除了 PrinterInfo 上的 isDefaultstatus 属性。

这些属性已从 PrinterInfo 对象中移除,因为它们已从上游 Chromium 中移除。

已弃用:session.serviceWorkers 上的 getFromVersionID

session.serviceWorkers.fromVersionID(versionId) API 已被弃用,建议使用 session.serviceWorkers.getInfoFromVersionID(versionId)。 此更改是为了在引入 session.serviceWorkers.getWorkerFromVersionID(versionId) API 后,更清楚地表明返回的是哪个对象。

// 已弃用
session.serviceWorkers.fromVersionID(versionId);

// 替换为
session.serviceWorkers.getInfoFromVersionID(versionId);

已弃用:Session 上的 setPreloadsgetPreloads

registerPreloadScriptunregisterPreloadScriptgetPreloadScripts 被引入作为对已弃用方法的替代。 这些新的 API 允许第三方库注册 preload scripts,而无需替换现有脚本。 此外,新的 type 选项允许超出 frame 的其他预加载目标。

// 已弃用
session.setPreloads([path.join(__dirname, 'preload.js')]);

// 替换为:
session.registerPreloadScript({
type: 'frame',
id: 'app-preload',
filePath: path.join(__dirname, 'preload.js'),
});

已弃用:WebContents 上的 console-message 事件中的 levelmessagelinesourceId 参数。

WebContents 上的 console-message 事件已更新,以提供有关 Event 参数的详细信息。

// 已弃用
webContents.on(
'console-message',
(event, level, message, line, sourceId) => {},
);

// 替换为:
webContents.on(
'console-message',
({ level, message, lineNumber, sourceId, frame }) => {},
);

此外,level 现在是一个字符串,可能的值为 infowarningerrordebug

行为变更:WebRequestFilterurls 属性。

之前,一个空的 URLs 数组被解释为包含所有 URL。 为了明确包含所有 URL,开发人员现在应该使用 <all_urls> 模式,这是一个与所有可能的 URL 匹配的 指定 URL 模式。 此更改阐明了意图,并确保行为更加可预测。

// 已弃用
const deprecatedFilter = {
urls: [],
};

// 替换为
const newFilter = {
urls: ['<all_urls>'],
};

已弃用:systemPreferences.isAeroGlassEnabled()

systemPreferences.isAeroGlassEnabled() 函数已被弃用,且没有替代方案。 自 Electron 23 起,它一直返回 true,因为 Electron 23 仅支持 Windows 10+,而 Windows 10+ 中 DWM 合成已无法禁用。

https://learn.microsoft.com/en-us/windows/win32/dwm/composition-ovw#disabling-dwm-composition-windows7-and-earlier

终止对 32.x.y 的支持

根据项目的支持政策,Electron 32.x.y 已经达到了支持的终点。 我们鼓励开发者将应用程序升级到更新的 Electron 版本。

E35 (2025 年 3 月)E36 (2025 年 4 月)E37 (2025 年 6 月)
35.x.y36.x.y37.x.y
34.x.y35.x.y36.x.y
33.x.y34.x.y35.x.y

接下来

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

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

有关这些和未来变化的更多信息可在计划的突破性变化页面找到。

Electron 34.0.0

· 阅读时间:约 5 分钟

Electron 34.0.0 已发布! 它包括对 Chromium 132.0.6834.83、V8 13.2 和 Node 20.18.1 的升级。


Electron 团队很高兴发布了 Electron 34.0.0 ! 你可以通过 npm install electron@latest 或者从我们的发布网站下载它。 继续阅读此版本的详细信息。

如果您有任何反馈,请在 BlueskyMastodon 上与我们分享,或加入我们的 Discord 社区! Bug 和功能请求可以在 Electron 的问题跟踪器中报告。

重要变化

HTTP Compression Shared Dictionary Management APIs

HTTP compression allows data to be compressed by a web server before being received by the browser. Modern versions of Chromium support Brotli and Zstandard, which are newer compression algorithms that perform better for text files than older schemes such as gzip.

Custom shared dictionaries further improve the efficiency of Brotli and Zstandard compression. See the Chrome for Developers blog on shared dictionaries for more information.

@felixrieseberg added the following APIs in #44950 to manage shared dictionaries at the Session level:

  • session.getSharedDictionaryUsageInfo()
  • session.getSharedDictionaryInfo(options)
  • session.clearSharedDictionaryCache()
  • session.clearSharedDictionaryCacheForIsolationKey(options)

Unresponsive Renderer JavaScript Call Stacks

Electron's unresponsive event occurs whenever a renderer process hangs for an excessive period of time. The new WebFrameMain.collectJavaScriptCallStack() API added by @samuelmaddock in #44204 allows you to collect the JavaScript call stack from the associated WebFrameMain object (webContnets.mainFrame).

This API can be useful to determine why the frame is unresponsive in cases where there's long-running JavaScript events causing the process to hang. For more information, see the proposed web standard Crash Reporting API.

Main Process
const { app } = require('electron');

app.commandLine.appendSwitch(
'enable-features',
'DocumentPolicyIncludeJSCallStacksInCrashReports',
);

app.on('web-contents-created', (_, webContents) => {
webContents.on('unresponsive', async () => {
// Interrupt execution and collect call stack from unresponsive renderer
const callStack = await webContents.mainFrame.collectJavaScriptCallStack();
console.log('Renderer unresponsive\n', callStack);
});
});
警告

This API requires the 'Document-Policy': 'include-js-call-stacks-in-crash-reports' header to be enabled. 详见: #45356

架构(Stack)更新

Electron 34 将 Chromium 从 130.0.6723.44 升级到 132.0.6834.83, Node 从 20.18.0 升级到 20.18.1 以及 V8 从 13.0 升级到 13.2

新特性

  • 添加了API以管理共享字典,以提高使用 Brotli 或 ZStandard 的压缩效率。 新的 APIs 是 session.getSharedDictionaryUsageInfo(), session.getSharedDictionaryInfo(options), session.clear. SharedDictionaryCache(), 和 session.clear. SharedDictionaryCacheForIsolation(options). #44950
  • 添加了 WebFrameMain.collectJavaScriptCallStack() 用于访问无响应渲染器的 JavaScript 调用堆栈。 #44938
  • 为处于卸载状态的帧添加了 WebFrameMain.detached
    • 添加了 WebFrameMain.isDestroyed() 方法,用于判断 frame 是否已被销毁。
    • 修复了 webFrameMain.fromId(processId, frameId) 在框架卸载时返回的 WebFrameMain 实例与给定参数不匹配的问题。 #43473
  • 在 utility process 中增加了 error 事件,以支持有关 V8 致命错误的诊断报告。 #43774
  • 新功能:GPU 加速的共享纹理离屏渲染。 #42953

重大更改

行为改变:在 Windows 全屏时,菜单栏将被隐藏

这使行为与Linux保持一致。 之前的行为:在 Windows 上全屏时菜单栏仍然可见。 新行为:在 Windows 全屏时隐藏菜单栏。

更正:之前这被列为 Electron 33 中的重大更改,但首次发布是在 Electron 34 中。

终止对 31.x.y 的支持

根据项目的支持政策,Electron 31.x.y 已经达到了支持的终点。 我们鼓励开发者将应用程序升级到更新的 Electron 版本。

E28 (25 年 1 月)E35 (25 年 4 月)E36 (25 年 6 月)
34.x.y35.x.y36.x.y
33.x.y34.x.y35.x.y
32.x.y33.x.y34.x.y

接下来

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

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

有关这些和未来变化的更多信息可在计划的突破性变化页面找到。

Electron 33.0.0

· 阅读时间:约 5 分钟

Electron 33.0.0 已发布! 它包括对 Chromium 130.0.6723.44、V8 13.0 和 Node 20.18.0 的升级。


Electron 团队很高兴发布了 Electron 33.0.0! 你可以通过 npm install electron@latest 或者从我们的发布网站下载它。 继续阅读此版本的详细信息。

如果您有任何反馈,请在 TwitterMastodon 上与我们分享,或加入我们的 Discord 社区! Bug 和功能请求可以在 Electron 的问题跟踪器中报告。

重要变化

重点内容

  • 添加了一个处理程序 app.setClientCertRequestPasswordHandler(handler),以帮助在需要 PIN 时解锁加密设备。 #41205
  • 扩展 navigationHistory API,增加两个新功能以改善 history 管理。 #42014
  • 改善了原生主题透明度检查。 #42862

架构(Stack)更新

Electron 33 将 Chromium 从 128.0.6613.36 升级到 130.0.6723.44, Node 从 20.16.0 升级到 20.18.0 以及 V8 从 12.8 升级到 13.0

新特性

  • 添加了一个处理程序 app.setClientCertRequestPasswordHandler(handler),以帮助在需要 PIN 时解锁加密设备。 #41205
  • 在 utility process 中增加了 error 事件,以支持有关 V8 致命错误的诊断报告。 #43997
  • 新增了 View.setBorderRadius(radius) 以自定义 view 的边框半径,并与 WebContentsView 兼容。 #42320
  • 扩展 navigationHistory API,增加两个新功能以改善 history 管理。 #42014

重大更改

移除:macOS 10.15 支持

macOS 10.15(Catalina)不再受到 Chromium 的支持。

旧版本的 Electron 将继续在 Catalina 上运行,但要运行 Electron v33.0.0 及更高版本,将需要 macOS 11(Big Sur)或更高版本。

行为变化:Native modules 现在需要 C++20

由于上游的改动,V8Node.js 现在要求 C++20 作为最低版本。 Developers using native node modules should build their modules with --std=c++20 rather than --std=c++17. 使用 gcc9 或更低版本的镜像可能需要更新到 gcc10 才能进行编译。 详见: #43555

行为变化:Windows 上的自定义协议 URL 处理

由于在 Chromium 中进行的更改,以支持非特殊方案 URL,使用 Windows 文件路径的自定义协议 URL 将不再与已弃用的 protocol.registerFileProtocolBrowserWindow.loadURLWebContents.loadURL 以及 <webview>.loadURL 上的 baseURLForDataURL 属性工作。 protocol.handle 也无法处理这些类型的 URL,但这并不是一个变化,因为它一直都是这样的工作方式。

// No longer works
protocol.registerFileProtocol('other', () => {
callback({ filePath: '/path/to/my/file' });
});

const mainWindow = new BrowserWindow();
mainWindow.loadURL(
'data:text/html,<script src="loaded-from-dataurl.js"></script>',
{ baseURLForDataURL: 'other://C:\\myapp' },
);
mainWindow.loadURL('other://C:\\myapp\\index.html');

// Replace with
const path = require('node:path');
const nodeUrl = require('node:url');
protocol.handle(other, (req) => {
const srcPath = 'C:\\myapp\\';
const reqURL = new URL(req.url);
return net.fetch(
nodeUrl.pathToFileURL(path.join(srcPath, reqURL.pathname)).toString(),
);
});

mainWindow.loadURL(
'data:text/html,<script src="loaded-from-dataurl.js"></script>',
{ baseURLForDataURL: 'other://' },
);
mainWindow.loadURL('other://index.html');

行为变化:app 上的 loginwebContents 属性

app 中的 login 事件的 webContents 属性在事件因来自于使用 respondToAuthRequestsFromMainProcess 选项创建的 utility process 的请求而被触发时,将为 null

已弃用: BrowserWindowConstructorOption.type 中的 textured 选项

BrowserWindowConstructorOptions 中的 typetextured 选项已被弃用,且没有替代方案。 此选项依赖于 macOS 上的 NSWindowStyleMaskTexturedBackground 样式掩码,该样式已被弃用且没有替代方案。

已弃用:systemPreferences.accessibilityDisplayShouldReduceTransparency

systemPreferences.accessibilityDisplayShouldReduceTransparency 属性现已被弃用,取而代之的是新的 nativeTheme.prefersReducedTransparency,它提供相同的信息并支持跨平台使用。

// Deprecated
const shouldReduceTransparency =
systemPreferences.accessibilityDisplayShouldReduceTransparency;

// Replace with:
const prefersReducedTransparency = nativeTheme.prefersReducedTransparency;

End of Support for 30.x.y

根据项目的支持政策,Electron 30.x.y 已经达到了支持的终点。 我们鼓励开发者将应用程序升级到更新的 Electron 版本。

E33 (24 年 10 月)E28 (25 年 1 月)E35 (25 年 4 月)
33.x.y34.x.y35.x.y
32.x.y33.x.y34.x.y
31.x.y32.x.y33.x.y

接下来

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

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

有关这些和未来变化的更多信息可在计划的突破性变化页面找到。

Electron 32.0.0

· 阅读时间:约 6 分钟

Electron 32.0.0 已发布! 包括升级 Chromium 128.0.6613.36,和 V8 12.8 以及 Node. js 20.16.2


Electron 团队很高兴发布了 Electron 32.0.0! 你可以通过 npm install electron@latest 或者从我们的发布网站下载它。 继续阅读此版本的详细信息。

如果您有任何反馈,请在 TwitterMastodon 上与我们分享,或加入我们的 Discord 社区! Bug 和功能请求可以在 Electron 的问题跟踪器中报告。

重要变化

重点内容

  • 在我们的文档中添加新的 API 版本历史,一个由 @piotrpdev 创建的功能,作为Google Summer 代码的一部分。 You can learn more about it in this blog post. #42982
  • 从 Web 文件 API 中移除非标准 File.path 扩展。 #42053
  • 尝试打开受阻止路径中的文件或目录时,将 Web File System API 中的故障路径与上游对齐。 #42993
  • 将以下现有的导航相关API添加到 webContents.navigationHistory : canGoBack, goBack, canGoForward, goForward, canGoToOffset, goToOffset, clear。 旧的导航API现已被废弃。 #41752

架构(Stack)更新

Electron 32 将 Chromium 从 026.0.6478.36 升级到 128.0.6613.36, Node 从 20.14.0 升级到 20.16.1 以及 V8 从 12.6 升级到 12.8

新特性

  • 添加了对通过app模块的'login'事件,响应来自实用程序进程发起的认证请求的支持。 #43317
  • CPUUsage结构中添加了cumulativeCPUUsage属性,该属性返回自进程启动以来使用的 CPU 时间的总秒数。 #41819
  • 将以下现有的导航相关API添加到 webContents.navigationHistory: canGoBack, goBack, canGoForward, goForward, canGoToOffset, goToOffset, clear#41752
  • 扩展 WebContentsView 以接受预先存在的 webContents 对象。 #42086
  • nativeTheme中添加了一个新属性prefersReducedTransparency,该属性指示用户是否选择通过系统辅助功能设置来降低操作系统级别的透明度。 #43137
  • 尝试打开阻塞路径中的文件或目录时,将文件系统访问 API 中的故障路径与上游对齐。 #42993
  • 在 Linux 上启用 Windows 控制叠加层API。 #42681
  • 在网络请求中启用 zstd 压缩。 #43300

重大更改

移除: File.path

Electron 的早期版本在 Web File 对象中添加了非标准 path 属性作为在渲染器中执行所有操作更为常见时处理本机文件的便捷方法。 然而它偏离了标准,并且也带来了较小的安全风险,因此从 Electron 32 开始它已被移除,取而代之的是 webUtils.getPathForFile 方法。

// Before (renderer)
const file = document.querySelector('input[type=file]');
alert(`Uploaded file path was: ${file.path}`);
// After (renderer)
const file = document.querySelector('input[type=file]');
electron.showFilePath(file);

// After (preload)
const { contextBridge, webUtils } = require('electron');

contextBridge.exposeInMainWorld('electron', {
showFilePath(file) {
// It's best not to expose the full file path to the web content if
// possible.
const path = webUtils.getPathForFile(file);
alert(`Uploaded file path was: ${path}`);
},
});

废弃:WebContents 中的 clearHistory, canGoBack, goBack, canGoForward, goForward, goToIndex, canGoToOffset, goToOffset

WebContents 实例上与导航相关的API现在已被废弃。 这些API已被移动到WebContentsnavigationHistory 属性,以便为管理导航历史提供一个更有条理和直观的接口。

// Deprecated
win.webContents.clearHistory();
win.webContents.canGoBack();
win.webContents.goBack();
win.webContents.canGoForward();
win.webContents.goForward();
win.webContents.goToIndex(index);
win.webContents.canGoToOffset();
win.webContents.goToOffset(index);

// Replace with
win.webContents.navigationHistory.clear();
win.webContents.navigationHistory.canGoBack();
win.webContents.navigationHistory.goBack();
win.webContents.navigationHistory.canGoForward();
win.webContents.navigationHistory.goForward();
win.webContents.navigationHistory.canGoToOffset();
win.webContents.navigationHistory.goToOffset(index);

Behavior changed: Directory databases in userData will be deleted

If you have a directory called databases in the directory returned by app.getPath('userData'), it will be deleted when Electron 32 is first run. The databases directory was used by WebSQL, which was removed in Electron 31. Chromium now performs a cleanup that deletes this directory. See issue #45396.

终止对 29.x.y 的支持

根据项目的支持政策,Electron 29.x.y 已经达到了支持的终点。 我们鼓励开发者将应用程序升级到更新的 Electron 版本。

E26(24 年 8月)E33 (24 年 10 月)E28 (25 年 1 月)
32.x.y33.x.y34.x.y
31.x.y32.x.y33.x.y
30.x.y31.x.y32.x.y

接下来

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

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

有关这些和未来变化的更多信息可在计划的突破性变化页面找到。

Electron 31.0.0

· 阅读时间:约 4 分钟

Electron 31.0.0 已发布! 包括升级 Chromium 126.0.6478.36,和 V8 12.6 以及 Node. js 20.14.2


Electron 团队很高兴发布了 Electron 31.0.0 ! 你可以通过 npm install electron@latest 或者从我们的发布网站下载它。 继续阅读此版本的详细信息。

如果您有任何反馈,请在 TwitterMastodon 上与我们分享,或加入我们的 Discord 社区! Bug 和功能请求可以在 Electron 的问题跟踪器中报告。

重要变化

重点内容

  • 扩展 WebContentsView 以接受预先存在的 webContents 对象 #42319
  • 添加了对 NODE_EXTRA_CA_CERTS 的支持。 #41689
  • 更新了 window.flashFrame(bool) 以在 macOS 上持续闪烁。 #41391
  • 移除了 WebSQL 支持。#41868
  • nativeImage.toDataURL 将保留 PNG 颜色空间 #41610
  • 扩展 webContents.setWindowOpenHandler 以支持手动创建 BrowserWindow。 #41432

架构(Stack)更新

Electron 31 将 Chromium 从 114.0.6367.49 升级到 122.. 0.661.39, Node 从 20.11.2 升级到 20.14.0,V8 从 12.4 升级到 12.6

新特性

  • 添加 clearData 方法支 Session. #40983
    • 添加参数到 Session.clearData API。 #41355
  • 添加了对 navigator.serial 中的服务类ID请求的蓝牙端口的支持。 #41638
  • 支持 Node's NODE_EXTRA_CA_CERTS 环境变量. #41689
  • 扩展 webContents.setWindowOpenHandler 以支持手动创建 BrowserWindow。 #41432
  • 实现了对 web 标准 File System API 的支持。 #41419
  • 扩展 WebContentsView 以接受预先存在的 webContents 对象 #42319
  • 在 webContents API 上添加了一个新的实例属性 navigationHistory,配合 navigationHistory.getEntryAtIndex 方法,使应用能够检索浏览历史中任何导航条目的 URL 和标题。 #41577 (Also in 29, 30)

重大更改

移除: WebSQL 的支持

Chromium has removed support for WebSQL upstream, transitioning it to Android only. 更多信息,请阅读 Chromium's 移除意图的讨论

行为变更:nativeImage.toDataURL 将保留 PNG 色彩空间。

PNG 解码器已支持保留颜色空间数据。 从此函数返回的编码数据现在与预期结果匹配。

更多信息,请阅读 crbug.com/332584706

行为变更:win.flashFrame(bool) 将在 macOS 上持续闪烁 Dock 图标。

This brings the behavior to parity with Windows and Linux. 之前的行为:第一次调用 flashFrame(true) 只会使 Dock 图标弹跳一次 (使用 NSInformationalRequest level),调用 flashFrame(false) 不会有任何效果。 现在的行为:持续闪烁,直到调用 flashFrame(false)。 使用了 NSCriticalRequest 级别替换。 如果要明确使用 NSInformationalRequest 使 Dock 图标弹跳一次,仍然可以使用 dock.bounce('informational').

终止对 28.x.y 的支持

根据项目的支持政策,Electron 28.x.y 已经达到了支持的终点。 我们鼓励开发者将应用程序升级到更新的 Electron 版本。

E31 (24 年 6 月)E26(24 年 8月)E33 (24 年 10 月)
31.x.y32.x.y33.x.y
30.x.y31.x.y32.x.y
28.x.y29.x.y31.x.y

接下来

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

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

有关这些和未来变化的更多信息可在计划的突破性变化页面找到。

Electron 30.0.0

· 阅读时间:约 6 分钟

Electron 30.0.0 已发布! 它包括对 Chromium 124.0.6367.49、V8 12.4 和 Node.js 20.11.1 的升级。


Electron 团队很高兴发布了 Electron 30.0.0 ! 你可以通过 npm install electron@latest 或者从我们的发布网站下载它。 继续阅读此版本的详细信息。

如果您有任何反馈,请在 TwitterMastodon 上与我们分享,或加入我们的 Discord 社区! Bug 和功能请求可以在 Electron 的问题跟踪器中报告。

重要变化

重点内容

  • Windows 现在支持 ASAR 完整性检查 (#40504)
    • 启用ASAR完整性的现有应用程序如果配置不正确,可能无法在Windows上工作。 使用 Electron 打包工具的应用应该升级到 @electron/packager@18.3.1@electron/forge@7.4.0
    • 查看我们的 ASAR Integrity 教程 以获取更多信息。
  • 添加了 WebContentsViewBaseWindow 主进程模块,废弃并替换 BrowserView (#35658). Learn more about how to migrate from BrowserView to WebContentsView in this blog post.
    • BrowserView 现在是 WebContentsView 的一个壳,并且旧的实现已被移除。
    • 查看 我们的 Web Embeds 文档 以便将新的 WebContentsView API 和其他类似 API进行比较。
  • 实现了对 File System API 的支持 (#41827)

架构(Stack)更新

Electron 30 将 Chromium 从 122.0.6261.39 升级到 124.0.6367.49, Node 从 20.9.0 升级到 20.11.1 以及 V8 从 12.2 升级到 12.4

新特性

  • 在 webviews 中添加了 transparent 网页偏好设置。 (#40301)
  • 在 webContents API 上添加了一个新的实例属性 navigationHistory,配合 navigationHistory.getEntryAtIndex 方法,使应用能够检索浏览历史中任何导航条目的 URL 和标题。 (#41662)
  • 新增了 BrowserWindow.isOccluded() 方法,允许应用检查窗口是否被遮挡。 (#38982)
  • 为工具进程中 net 模块发出的请求添加了代理配置支持。 (#41417)
  • 添加了对 navigator.serial 中的服务类ID请求的蓝牙端口的支持。 (#41734)
  • 添加了对 Node.js NODE_EXTRA_CA_CERTS 命令行标志的支持。 (#41822)

重大更改

行为变更:跨源 iframe 现在使用 Permission Policy 来访问功能。

跨域 iframe 现在必须通过 allow 属性指定一个给定 iframe 可以访问的功能。

有关更多信息,请参见 文档

移除:--disable-color-correct-rendering 命令行开关

此开关从未正式文档化,但无论如何这里都记录了它的移除。 Chromium 本身现在对颜色空间有更好的支持,因此不再需要该标志。

行为变更:BrowserView.setAutoResize 在 macOS 上的行为

在 Electron 30 中,BrowserView 现在是围绕新的 WebContentsView API 的包装器。

以前,BrowserView API 的 setAutoResize 功能在 macOS 上由 autoresizing 支持,并且在 Windows 和 Linux 上由自定义算法支持。 对于简单的用例,比如使 BrowserView 填充整个窗口,在这两种方法的行为上是相同的。 然而,在更高级的情况下,BrowserViews 在 macOS 上的自动调整大小与在其他平台上的情况不同,因为 Windows 和 Linux 的自定义调整大小算法与 macOS 的自动调整大小 API 的行为并不完全匹配。 自动调整大小的行为现在在所有平台上都标准化了。

如果您的应用使用 BrowserView.setAutoResize 做的不仅仅是使 BrowserView 填满整个窗口,那么您可能已经有了自定义逻辑来处理 macOS 上的这种行为差异。 如果是这样,在 Electron 30 中不再需要这种逻辑,因为自动调整大小的行为是一致的。

移除:WebContentscontext-menuparams.inputFormType 属性

WebContentscontext-menu 事件中 params 对象的 inputFormType 属性已被移除。 请改用新的 formControlType 属性。

移除:process.getIOCounters()

Chromium 已删除对这些信息的访问。

终止对 27.x.y 的支持

根据项目的支持政策,Electron 27.x.y 已经达到了支持的终点。 我们鼓励开发者将应用程序升级到更新的 Electron 版本。

E30(24 年 4 月)E31 (24 年 6 月)E26(24 年 8月)
30.x.y31.x.y32.x.y
29.x.y30.x.y31.x.y
28.x.y29.x.y30.x.y

接下来

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

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

有关这些和未来变化的更多信息可在计划的突破性变化页面找到。

Electron 29.0.0

· 阅读时间:约 5 分钟

Electron 29.0.0 已发布! 它包括升级 Chromium 122.0.6261.39,和 V8 12.2 以及 Node.js 20.9.2


Electron 团队很高兴发布了 Electron 29.0.0 ! 你可以通过 npm install electron@latest 或者从我们的发布网站下载它。 继续阅读此版本的详细信息。

如果您有任何反馈,请在 TwitterMastodon 上与我们分享,或加入我们的 Discord 社区! Bug 和功能请求可以在 Electron 的问题跟踪器中报告。

重要变化

重点内容

  • 添加了一个新的顶级 webUtils 模块,这是一个渲染进程模块,提供与 Web API 对象交互的实用程序层。 模块中第一个可用的 API 是 webUtils.getPathForFile。 Electron 以前的 File.path 扩充偏离了网页标准;这个新的 API 更符合当前的 web 标准行为。

架构(Stack)更新

Electron 29 将 Chromium 从 120.0.6099.56 升级到 122..0.661.39, Node 从 18.18.2 升级到 20.9.0,V8 从 12.0 升级到 12.2

新特性

  • 添加了新的 webUtils 模块,一个与 Web API 对象交互的实用程序层,替换 File.path 扩充。 #38776
  • 添加 net 模块到 utility process#40890
  • 添加了一个新的 Electron FusegrantFileProtocolExtravilegesfile:// 协议使其具有更安全和更严格的行为,与 Chromium 相匹配。 #40372
  • protocol.registerSchemesAsseged 中添加了一个选项,以允许自定义协议开启 V8 code cache。 #40544
  • 迁移 app.{set|get}LoginItemSettings(settings) 以便在 MacOS 13.0+ 上使用 Apple 推荐的新底层框架。 #37244

重大更改

行为改变:ipcRenderer 不能再通过 contextBridge 发送

现在通过 contextBridge 传送整个 ipcRenderer 模块作为对象,会在 bridge 的接收方收到一个 空对象。 此更改是为了消除/减轻一种安全隐患。 你不应该直接暴露 bridge 上的 ipcRenderer 或它的方法。 相反,应该提供一个像下面这样的安全包装器:

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

移除:app 上的 render-process-crashed 事件

The renderer-process-crashed event on app has been removed. 改用新的 render-process-gone 事件。

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

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

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

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

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

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

Removed: gpu-process-crashed event on app

app 上的 gpu-process-crashed 事件已被移除。 使用新的 child-process-gone 事件代替。

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

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

终止对 26.x.y 的支持

根据项目的支持政策,Electron 26.x.y 已经达到了支持的终点。 我们鼓励开发者将应用程序升级到更新的 Electron 版本。

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

接下来

您是否知道 Electron 最近添加了社区征求意见 (RFC) 流程? 如果您想在框架中添加一项功能,RFC 可以成为您与维护者就功能设计展开对话的有用工具。 您还可以查看 PR 中正在讨论的即将发生的更改。 若要了解更多信息,请直接查看我们的 introduction electron/rfcs 博客文章,或查看 electron/rfcs 版本库的 README。

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

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

有关这些和未来变化的更多信息可在计划的突破性变化页面找到。

Electron 28.0.0

· 阅读时间:约 5 分钟

Electron 28.0.0 已发布! 它包括升级 Chromium 120.0.6099.56 和 V8 12.0 以及 Node.js 18.18.2


Electron 团队很高兴发布了 Electron 28.0.0 ! 你可以通过 npm install electron@latest 或者从我们的发布网站下载它。 继续阅读此版本的详细信息。

如果您有任何反馈,请在 TwitterMastodon 上与我们分享,或加入我们的 Discord 社区! Bug 和功能请求可以在 Electron 的问题跟踪器中报告。

重要变化

重点内容

  • 实现了对 ECMAScript 模块或 ESM 的支持(什么是 ECMAScript 模块?) 在这里了解更多信息. 这包括在 Electron 本身中支持 ESM,以及诸如 UtilityProcess API 入口点等方面。 详情见我们的 ESM 文档 以获取更多详细信息。
  • 除了在 Electron 本身中启用 ESM 支持外,Electron Forge 还支持使用 ESM 来打包、构建和开发 Electron 应用程序。 您可以在 Forge v7.0.0 或更高版本中找到这种支持。

架构(Stack)更新

新特性

  • 启用 ESM 支持。 #37535
  • UtilityProcess API 添加了 ESM 入口点。 #40047
  • 添加了几个属性到 display 对象中,包括 detectedmaximumCursorSizenativeOrigin#40554
  • 新增对 Linux 上 ELECTRON_OZONE_PLATFORM_HINT 环境变量的支持。 #39792

重大更改

行为改变:在宿主 BrowserWindow 中将 WebContents.backgroundThrottling 设置为 false 将影响所有的 WebContents

WebContents.backgroundThrottling 设置为 false 将禁用由 BrowserWindow 显示的所有 WebContents 的帧节流。

移除: BrowserWindow.setTrafficLightPosition(position)

已经移除了 BrowserWindow.setTrafficLightPosition(position) 方法,应该改用 BrowserWindow.setWindowButtonPosition(position)方法。新的方法接受 null 作为替换 { x: 0, y: 0 } 的参数,以将位置重置为系统默认值。

// 在 Electron 28 移除
win.setTrafficLightPosition({ x: 10, y: 10 });
win.setTrafficLightPosition({ x: 0, y: 0 });

// 代替为
win.setWindowButtonPosition({ x: 10, y: 10 });
win.setWindowButtonPosition(null);

移除: BrowserWindow.getTrafficLightPosition()

已经删除了 BrowserWindow.getTrafficLightPosition(),应该使用 BrowserWindow.getWindowButtonPosition() API 代替,当没有自定义位置时,它返回 null 而不是 { x: 0, y: 0 }

// 在 Electron 28 移除
const pos = win.getTrafficLightPosition();
if (pos.x === 0 && pos.y === 0) {
// 没有自定义位置
}

// 代替为
const ret = win.getWindowButtonPosition();
if (ret === null) {
// 没有自定义位置
}

移除: ipcRenderer.sendTo()

ipcRenderer.sendTo() API 已经被删除。 应该用渲染进程之间的 MessageChannel 来替代它

IpcRendererEventsenderIdsenderIsMainFrame 属性也已经被移除。

移除: app.runningUnderRosettaTranslation

app.runningUnderRosettaTranslation 属性已经被移除。 使用 app.runningUnderARM64Translation 代替.

// 移除
console.log(app.runningUnderRosettaTranslation);
// 代替为
console.log(app.runningUnderARM64Translation);

终止对 25.x.y 的支持

根据项目的支持政策,Electron 25.x.y 已经达到了支持的终点。 我们鼓励开发者将应用程序升级到更新的 Electron 版本。

E28(23 年 12 月)E29(24 年 2 月)E30(24 年 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 的公开时间表

有关这些和未来变化的更多信息可在计划的突破性变化页面找到。

Electron 27.0.0

· 阅读时间:约 5 分钟

Electron 27.0.0 已发布! 此次升级中包含 Chromium 118.0.5993.32,V8 11.8,和 Node.js 18.17.1


Electron 团队很高兴发布了 Electron 27.0.0! 您可以通过 npm install electron@latest 进行安装,或者从我们的 发布网站 下载它。 继续阅读此版本的详细信息。

如果您有任何反馈,请在 TwitterMastodon 上与我们分享,或加入我们的 Discord 社区! Bug 和功能请求可以在 Electron 的 问题跟踪器 中报告。

重要变化

架构(Stack)更新

重大更改

已移除:macOS 10.13 / 10.14 / 支援

macOS 10.13 (High Serria) 和 macOS 10.14 (Mojave) 不再支援Chromium.

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

弃用:ipcRenderer.sendTo()

ipcRenderer.sendTo() 已被弃用。 可以通过在渲染器之间设置一个 MessageChannel 来替换它。

IpcRendererEventsenderIdsenderIsMainFrame 属性也已被弃用。

已删除: systemPreferences 中的 color scheme 相关事件

以下 systemPreferences 事件已被删除:

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

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

// 已删除
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}AppLevelAppearancesystemPreferences.appLevelAppearance

方法 systemPreferences.getAppLevelAppearancesystemPreferences.setAppLevelAppearance 已被删除,也包括属性 systemPreferences.appLevelAppearance。 请改用模块 nativeTheme

// 已删除
systemPreferences.getAppLevelAppearance();
// 替换为
nativeTheme.shouldUseDarkColors;

// 已删除
systemPreferences.appLevelAppearance;
// 替换为
nativeTheme.shouldUseDarkColors;

// 已删除
systemPreferences.setAppLevelAppearance('dark');
// 替换为
nativeTheme.themeSource = 'dark';

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

systemPreferences.getColoralternate-selected-control-text 值已被删除。 替换为 selected-content-background

// 已删除
systemPreferences.getColor('alternate-selected-control-text');
// 替换为
systemPreferences.getColor('selected-content-background');

新特性

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

终止对 24.x.y 的支持

根据项目的支持政策,Electron 24.x.y 已经达到了支持的终点。 我们鼓励开发者将应用程序升级到更新的 Electron 版本。

E27(23 年 10 月)E22 (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 的扩展支持(详情请查看 Farewell, Windows 7/8/8.1)。

根据项目的支持政策和此支持扩展,Electron 22.x.y 已经达到了支持的终点。 这将恢复到支持最新的三个稳定的主要版本,并将结束对 Windows 7/8.1 的官方支持。

接下来

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

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

有关这些和未来变化的更多信息可在 计划的突破性变化 页面找到。

Electron 26.0.0

· 阅读时间:约 3 分钟

Electron 26.0.0 已发布! 此次升级中包含 Chromium 116.0.5845.62,V8 11.2,和 Node.js 18.16.1 。 请阅读下文了解更多详情!


Electron 团队很高兴发布了 Electron 26.0.0 ! 您可以通过 npm install electron@latest 进行安装,或者从我们的 发布网站 下载它。 继续阅读此版本的详细信息。

如果您有任何反馈,请在Twitter上与我们分享,或加入我们的社区 Discord! Bug 和功能请求可以在 Electron 的 问题跟踪器 中报告。

重要变化

架构(Stack)更新

重大更改

弃用: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}AppLevelAppearancesystemPreferences.appLevelAppearance

方法systemPreferences.getAppLevelAppearancesystemPreferences.setAppLevelAppearance 已被弃用,也包括属性 systemPreferences.appLevelAppearance。 请改用模块 nativeTheme

// 被弃用
systemPreferences.getAppLevelAppearance();
// 替换为
nativeTheme.shouldUseDarkColors;

// 被弃用
systemPreferences.appLevelAppearance;
// 替换为
nativeTheme.shouldUseDarkColors;

// 被弃用
systemPreferences.setAppLevelAppearance('dark');
// 替换为
nativeTheme.themeSource = 'dark';

弃用:systemPreferences.getColoralternate-selected-control-text

systemPreferences.getColoralternate-selected-control-text 值已被弃用。 替换为 selected-content-background

// 被弃用
systemPreferences.getColor('alternate-selected-control-text');
// 替换为
systemPreferences.getColor('selected-content-background');

新特性

  • 添加了 safeStorage.setUsePlainTextEncryptionsafeStorage.getSelectedStorageBackend api。 #39107
  • 添加了 safeStorage.setUsePlainTextEncryptionsafeStorage.getSelectedStorageBackend api。 #39155
  • senderIsMainFrame添加到通过ipcRenderer.sendTo()发送的消息中。 #39206
  • 添加了由键盘初始化菜单弹出的支持。 #38954

终止对 23.x.y 的支持

根据项目的支持政策,Electron 23.x.y 已经达到了支持的终点。 我们鼓励开发者将应用程序升级到更新的 Electron 版本。

E26(23 年 8月)E27(23 年 10 月)E28(24 年 1 月)
26.x.y27.x.y28.x.y
25.x.y26.x.y27.x.y
24.x.y25.x.y26.x.y
22.x.y

接下来

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

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

有关这些和未来变化的更多信息可在 计划的突破性变化 页面找到。