From 7011cdd0c125255c4b2676de562b8409294955cb Mon Sep 17 00:00:00 2001 From: kj1352 Date: Tue, 10 Dec 2024 20:34:12 +0530 Subject: [PATCH] fix: move the app to system tray when closed --- main.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/main.js b/main.js index 1affefa..27e79b1 100644 --- a/main.js +++ b/main.js @@ -40,20 +40,23 @@ app.on('ready', () => { }); function createMainWindow() { - const userDataPath = path.join(app.getPath('userData'), 'Cache'); - mainWindow = new BrowserWindow({ width: 800, height: 600, webPreferences: { preload: path.join(__dirname, 'preload.js'), - nodeIntegration: false, contextIsolation: true, + nodeIntegration: false, }, }); - app.setPath('userData', userDataPath); mainWindow.loadFile('index.html'); + + // Hide the window instead of quitting + mainWindow.on('close', (event) => { + event.preventDefault(); + mainWindow.hide(); + }); } async function sendAPIRequest(data = {}) {