feat/tray #1
@@ -60,9 +60,22 @@ const initBackend = () => {
|
||||
};
|
||||
// --- System Tray ---
|
||||
const createTray = () => {
|
||||
const iconPath = path_1.default.join(electron_1.app.getAppPath(), isDev ? 'assets-build/icon.png' : '../assets-build/icon.png');
|
||||
if (!fs_1.default.existsSync(iconPath))
|
||||
const assetsDir = path_1.default.join(__dirname, '..', 'assets-build');
|
||||
const possibleIcons = ['icon.svg', 'icon.png'];
|
||||
let iconPath = '';
|
||||
for (const name of possibleIcons) {
|
||||
const fullPath = path_1.default.join(assetsDir, name);
|
||||
if (fs_1.default.existsSync(fullPath)) {
|
||||
iconPath = fullPath;
|
||||
break;
|
||||
}
|
||||
}
|
||||
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');
|
||||
@@ -73,6 +86,11 @@ const createTray = () => {
|
||||
}
|
||||
});
|
||||
updateTrayMenu();
|
||||
console.log(`[Tray] Successfully initialized`);
|
||||
}
|
||||
catch (e) {
|
||||
console.error(`[Tray] Critical error during initialization: ${e.message}`);
|
||||
}
|
||||
};
|
||||
const updateTrayMenu = () => {
|
||||
if (!tray)
|
||||
|
||||
@@ -91,9 +91,26 @@ const initBackend = () => {
|
||||
|
||||
// --- System Tray ---
|
||||
const createTray = () => {
|
||||
const iconPath = path.join(app.getAppPath(), isDev ? 'assets-build/icon.png' : '../assets-build/icon.png');
|
||||
if (!fs.existsSync(iconPath)) return;
|
||||
const assetsDir = path.join(__dirname, '..', 'assets-build');
|
||||
const possibleIcons = ['icon.svg', 'icon.png'];
|
||||
let iconPath = '';
|
||||
|
||||
for (const name of possibleIcons) {
|
||||
const fullPath = path.join(assetsDir, name);
|
||||
if (fs.existsSync(fullPath)) {
|
||||
iconPath = fullPath;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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');
|
||||
@@ -104,6 +121,10 @@ const createTray = () => {
|
||||
}
|
||||
});
|
||||
updateTrayMenu();
|
||||
console.log(`[Tray] Successfully initialized`);
|
||||
} catch (e: any) {
|
||||
console.error(`[Tray] Critical error during initialization: ${e.message}`);
|
||||
}
|
||||
};
|
||||
|
||||
const updateTrayMenu = () => {
|
||||
|
||||
Reference in New Issue
Block a user