// main.js // const { app, BrowserWindow} = require('electron'); const { app, BrowserWindow, ipcMain } = require('electron'); const fs = require('fs'); const path = require('path'); const jquery = require('jquery'); let onlineStatus = true; const { dialog } = require('electron'); const saveFile = require('./savexml') let mainWindow; async function createWindow() { mainWindow = new BrowserWindow({ width: 1200, height: 800, webPreferences: { nodeIntegration: true, contextIsolation: false, }, }); mainWindow.loadFile('dashboard.html'); // Create an HTML file for your interface mainWindow.on('closed', function () { mainWindow = null; }); // setInterval(checkInternetConnection, 5000); } async function checkInternetConnection() { try { const response = await fetch('https://www.google.com'); if (response.ok && onlineStatus) { onlineStatus = false; // mainWindow.webContents.send('online'); dialog.showMessageBox(mainWindow, { type: 'info', message: 'Internet is available. Click OK to close the app. Otherwise app will auto close in 10 seconds', buttons: ['OK'], }); setTimeout(() => { app.quit(); }, 10000); } else if (!response.ok && !onlineStatus) { onlineStatus = true; // mainWindow.webContents.send('offline'); } } catch (error) { console.error('Error checking internet connection'); } } app.on('ready', createWindow); app.on('window-all-closed', function () { if (process.platform !== 'darwin') { app.quit(); } }); app.on('activate', function () { if (mainWindow === null) { createWindow(); } });