feat/tray #1

Merged
nvrl merged 2 commits from feat/tray into main 2026-02-21 02:04:33 +01:00
2 changed files with 63 additions and 24 deletions
Showing only changes of commit b7e22b33af - Show all commits

View File

@@ -60,19 +60,37 @@ const initBackend = () => {
}; };
// --- System Tray --- // --- System Tray ---
const createTray = () => { const createTray = () => {
const iconPath = path_1.default.join(electron_1.app.getAppPath(), isDev ? 'assets-build/icon.png' : '../assets-build/icon.png'); const assetsDir = path_1.default.join(__dirname, '..', 'assets-build');
if (!fs_1.default.existsSync(iconPath)) const possibleIcons = ['icon.svg', 'icon.png'];
return; let iconPath = '';
const icon = electron_1.nativeImage.createFromPath(iconPath).resize({ width: 16, height: 16 }); for (const name of possibleIcons) {
tray = new electron_1.Tray(icon); const fullPath = path_1.default.join(assetsDir, name);
tray.setToolTip('Ultimate Ban Tracker'); if (fs_1.default.existsSync(fullPath)) {
tray.on('click', () => { iconPath = fullPath;
if (mainWindow) { break;
mainWindow.show();
mainWindow.focus();
} }
}); }
updateTrayMenu(); console.log(`[Tray] Attempting to initialize with icon: ${iconPath || 'NONE FOUND'}`);
if (!iconPath) {
console.warn(`[Tray] FAILED: No valid icon found in ${assetsDir}`);
return;
}
try {
const icon = electron_1.nativeImage.createFromPath(iconPath).resize({ width: 16, height: 16 });
tray = new electron_1.Tray(icon);
tray.setToolTip('Ultimate Ban Tracker');
tray.on('click', () => {
if (mainWindow) {
mainWindow.show();
mainWindow.focus();
}
});
updateTrayMenu();
console.log(`[Tray] Successfully initialized`);
}
catch (e) {
console.error(`[Tray] Critical error during initialization: ${e.message}`);
}
}; };
const updateTrayMenu = () => { const updateTrayMenu = () => {
if (!tray) if (!tray)

View File

@@ -91,19 +91,40 @@ const initBackend = () => {
// --- System Tray --- // --- System Tray ---
const createTray = () => { const createTray = () => {
const iconPath = path.join(app.getAppPath(), isDev ? 'assets-build/icon.png' : '../assets-build/icon.png'); const assetsDir = path.join(__dirname, '..', 'assets-build');
if (!fs.existsSync(iconPath)) return; const possibleIcons = ['icon.svg', 'icon.png'];
let iconPath = '';
const icon = nativeImage.createFromPath(iconPath).resize({ width: 16, height: 16 }); for (const name of possibleIcons) {
tray = new Tray(icon); const fullPath = path.join(assetsDir, name);
tray.setToolTip('Ultimate Ban Tracker'); if (fs.existsSync(fullPath)) {
tray.on('click', () => { iconPath = fullPath;
if (mainWindow) { break;
mainWindow.show();
mainWindow.focus();
} }
}); }
updateTrayMenu();
console.log(`[Tray] Attempting to initialize with icon: ${iconPath || 'NONE FOUND'}`);
if (!iconPath) {
console.warn(`[Tray] FAILED: No valid icon found in ${assetsDir}`);
return;
}
try {
const icon = nativeImage.createFromPath(iconPath).resize({ width: 16, height: 16 });
tray = new Tray(icon);
tray.setToolTip('Ultimate Ban Tracker');
tray.on('click', () => {
if (mainWindow) {
mainWindow.show();
mainWindow.focus();
}
});
updateTrayMenu();
console.log(`[Tray] Successfully initialized`);
} catch (e: any) {
console.error(`[Tray] Critical error during initialization: ${e.message}`);
}
}; };
const updateTrayMenu = () => { const updateTrayMenu = () => {