Skip to content

Commit

Permalink
Update main.js
Browse files Browse the repository at this point in the history
  • Loading branch information
withinJoel authored Nov 5, 2024
1 parent 4a0bda0 commit 0f246db
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
// Import necessary modules
const { app, BrowserWindow, screen, Menu, ipcMain, dialog } = require('electron');
const path = require('path');
const os = require('os'); //For OS details
const axios = require('axios'); //For http request
const os = require('os'); // For OS details
const axios = require('axios'); // For HTTP requests
const fs = require('fs');
const { exec } = require('child_process'); //To execute stuffs
const { exec } = require('child_process'); // To execute commands

// Initialize electron-context-menu with default settings
require('electron-context-menu')({
showInspectElement: false, // Disable the "Inspect Element" option
// Add more customization options as needed
});

// Function to create the main application window
function createWindow() {
const { width, height } = screen.getPrimaryDisplay().workAreaSize;

Expand Down Expand Up @@ -37,7 +45,7 @@ function createWindow() {
worldSafeExecuteJavaScript: true,
additionalArguments: ['--allow-file-access-from-files'],
safeDialogs: true,
preload: path.join(__dirname, 'preload.js'), // Add this line to load the preload script
preload: path.join(__dirname, 'preload.js'), // Load the preload script
},
});

Expand Down Expand Up @@ -69,7 +77,7 @@ function createWindow() {
}
::-webkit-scrollbar-thumb {
background: white;
border-radius:30px;
border-radius: 30px;
-webkit-app-region: no-drag; /* Make scrollbar thumb non-draggable */
}
::-webkit-scrollbar-thumb:hover {
Expand All @@ -79,6 +87,23 @@ function createWindow() {
});
}

// Electron app lifecycle events
app.whenReady().then(() => {
createWindow();

app.on('activate', () => {
// On macOS, recreate a window when the dock icon is clicked and there are no other windows open.
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
});

app.on('window-all-closed', () => {
// On macOS, it's common for applications to stay open until the user explicitly quits.
if (process.platform !== 'darwin') {
app.quit();
}
});

///////////////////////////////Update
let isCheckingForUpdates = false;

Expand Down Expand Up @@ -987,4 +1012,4 @@ app.on('activate', function () {
if (mainWindow === null) {
createWindow();
}
});
});

0 comments on commit 0f246db

Please sign in to comment.