Browse Source

feature: craete task tray

master
kj1352 10 months ago
parent
commit
a403763805
3 changed files with 29 additions and 2 deletions
  1. BIN
      logo.png
  2. +28
    -1
      main.js
  3. +1
    -1
      package.json

BIN
logo.png View File

Before After
Width: 75  |  Height: 53  |  Size: 1.0 KiB

+ 28
- 1
main.js View File

@@ -1,12 +1,14 @@
const { app, BrowserWindow, powerMonitor } = require('electron');
const { app, BrowserWindow, powerMonitor, Tray, Menu } = require('electron');
const path = require('path');
const os = require('os');

let tray;
let mainWindow;
const endpoint = "https://workx.webtrigon.com/api/v1/device/presence/";

app.on('ready', () => {
createMainWindow();
createTray();

const macAddress = getMacAddress();
console.log('MAC Address:', macAddress);
@@ -92,3 +94,28 @@ function getMacAddress() {
}
return null; // If no MAC address found
}

function createTray() {
tray = new Tray(path.join(__dirname, 'logo.png'));
const contextMenu = Menu.buildFromTemplate([
{
label: 'Show App',
click: () => {
mainWindow.show(); // Show the main window
},
},
{
label: 'Quit',
click: () => {
app.quit(); // Quit the app
},
},
]);

tray.setToolTip('Monitoring Tool');
tray.setContextMenu(contextMenu);

tray.on('click', () => {
mainWindow.show(); // Show the main window when the tray icon is clicked
});
}

+ 1
- 1
package.json View File

@@ -1,5 +1,5 @@
{
"name": "checkin-bot",
"name": "project-deep-water",
"version": "1.0.0",
"description": "A cross-platform monitoring tool",
"main": "main.js",


Loading…
Cancel
Save