我知道,如果您有Session实例,则有一个用于清除Session数据的API,但是可以删除所有Session吗?
答案 0 :(得分:1)
可能 (我还没有尝试过):
使用webContents.getAllWebContents()
获取所有WebContents
实例
返回WebContents []-所有WebContents实例的数组。这将包含所有窗口,Web视图,打开的devtools和devtools扩展背景页面的Web内容。
然后对于每个WebContents
实例,使用contents.session
Session
实例
此webContents使用的会话。
因此它看起来像:(在主过程中)
const { webContents } = require('electron')
webContents.getAllWebContents().forEach(contents => {
contents.session.clearCache(/* some arguments */);
contents.session.clearStorageData(/* some arguments */);
});