ソースを参照

feature: craete task tray

master
kj1352 1年前
コミット
a403763805
3個のファイルの変更29行の追加2行の削除
  1. バイナリ
      logo.png
  2. +28
    -1
      main.js
  3. +1
    -1
      package.json

バイナリ
logo.png ファイルの表示

変更前 変更後
幅: 75  |  高さ: 53  |  サイズ: 1.0 KiB

+ 28
- 1
main.js ファイルの表示

@@ -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 ファイルの表示

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


読み込み中…
キャンセル
保存