gpt4 book ai didi

electron - 如何从 Electron 中的 WebContents 获取 BrowserWindow?

转载 作者:行者123 更新时间:2023-12-03 12:21:09 26 4
gpt4 key购买 nike

这可能让我眼前一亮,但是给定 WebContents 我如何找到相应的 BrowserWindow

在我的头顶我可以做到

const windows = BrowserWindow.getAllWindows();
const ndx = windows.indexOf(someWebContents);
const window = windows[ndx];

有没有更简单的方法?

最佳答案

这个 BrowserWindow 静态方法似乎是最直接的方式:

BrowserWindow.fromWebContents(webContents)

Returns BrowserWindow - The window that owns the given webContents.

关于electron - 如何从 Electron 中的 WebContents 获取 BrowserWindow?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49109048/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com