在菜单栏添加清除按钮
配置清除项
const clearObj = {
storages: ['appcache', 'filesystem', 'indexdb', 'localstorage', 'shadercache', 'websql', 'serviceworkers', 'cachestorage'],
};
工具栏
{
label: '重载',
accelerator: 'CmdOrCtrl+R',
click: (item, focusedWindow) => {
if (focusedWindow) {
// 重载之后, 刷新并关闭所有之前打开的次要窗体
if (focusedWindow.id === 1) {
BrowserWindow.getAllWindows().forEach((win) => {
if (win.id > 1) win.close();
});
}
focusedWindow.webContents.session.clearStorageData(clearObj,() => {
focusedWindow.reload();
})
}
},
},
{
label: '清除缓存数据',
accelerator: 'CmdOrCtrl+Shift+Delete',
click: (item,focusedWindow) => {
if (focusedWindow) {
focusedWindow.webContents.session.clearStorageData(clearObj);
}
}
},
也可以使用开发者工具进行清除 chrome开发者工具