在菜單欄添加清除按鈕
配置清除項
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開發者工具