From d3d17da2c83417dc3abd9e279e9e60b1a820d7a8 Mon Sep 17 00:00:00 2001 From: proitlab Date: Mon, 22 Dec 2025 17:17:53 +0700 Subject: [PATCH] Clear Cache everytime start --- main.js | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/main.js b/main.js index 6e06df5..145cb01 100644 --- a/main.js +++ b/main.js @@ -64,11 +64,40 @@ const createWindow = () => { }); */ //win.loadURL('https://nexus.manage.backone.cloud/') - const ses = win.webContents.session - ses.clearCache() + //const ses = win.webContents.session + //ses.clearCache() } +app.on('ready', async () => { + // Clear the default session's cache before the window is ready to load content + try { + await session.defaultSession.clearCache(); + console.log('Cache cleared successfully on app start.'); + } catch (err) { + console.error('Failed to clear cache:', err); + } + createWindow(); + + + // Quit app when all windows are closed, except on macOS (common pattern) + app.on('window-all-closed', () => { + if (process.platform !== 'darwin') { + app.quit(); + } + }); + + app.on('activate', () => { + // Recreate a window in the app when the dock icon is clicked (macOS) + if (BrowserWindow.getAllWindows().length === 0) { + createWindow(); + } + }); +}); + + + +/* app.whenReady().then(() => { createWindow() @@ -82,3 +111,4 @@ app.whenReady().then(() => { app.on('window-all-closed', () => { if (process.platform !== 'darwin') app.quit() }) +*/