From 38c4c7baa29524b95069b93bf5c75089929b9033 Mon Sep 17 00:00:00 2001 From: AlphaX-Projects <77661270+AlphaX-Projects@users.noreply.github.com> Date: Sun, 23 Jul 2023 18:01:30 +0200 Subject: [PATCH] Add clear cache --- electron.js | 31 +++++++++++++++++++------------ lib/preload.js | 1 + 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/electron.js b/electron.js index ffbc9538..7190f5c3 100644 --- a/electron.js +++ b/electron.js @@ -1,16 +1,17 @@ const { - app, - BrowserWindow, - ipcMain, - ipcRenderer, - Menu, - Notification, - Tray, - nativeImage, - dialog, - webContents, - nativeTheme, - crashReporter + app, + BrowserWindow, + ipcMain, + ipcRenderer, + Menu, + Notification, + Tray, + nativeImage, + dialog, + webContents, + nativeTheme, + crashReporter, + webFrame } = require('electron') const { autoUpdater } = require('electron-updater') @@ -1031,6 +1032,12 @@ if (!isLock) { } }) }) + ipcMain.on('clear-all-cache', (event) => { + const theWindows = BrowserWindow.getAllWindows()[0] + const ses = theWindows.webContents.session + console.clear() + ses.clearCache() + }) ipcMain.on('check-for-update', (event) => { const check = new Notification({ title: i18n.__("electron_translate_43"), diff --git a/lib/preload.js b/lib/preload.js index fed27281..7f3a0cf8 100644 --- a/lib/preload.js +++ b/lib/preload.js @@ -5,4 +5,5 @@ contextBridge.exposeInMainWorld('electronAPI', { checkForUpdate: () => ipcRenderer.send('check-for-update'), showMyMenu: () => ipcRenderer.send('show-my-menu'), focusApp: () => ipcRenderer.send('focus-app'), + clearMyCache: () => ipcRenderer.send('clear-all-cache'), }) \ No newline at end of file