diff --git a/main.js b/main.js index 1add692..286bd7e 100644 --- a/main.js +++ b/main.js @@ -1,6 +1,6 @@ process.env.UV_THREADPOOL_SIZE = process.env.UV_THREADPOOL_SIZE || '64'; const { monitorEventLoopDelay } = require('perf_hooks'); -const { app, BrowserWindow, ipcMain, dialog, clipboard, nativeTheme, Tray, Menu } = require('electron'); +const { app, BrowserWindow, ipcMain, dialog, clipboard, nativeTheme, Tray, Menu, nativeImage } = require('electron'); nativeTheme.themeSource = 'dark'; const path = require('path'); const fs = require('fs'); @@ -225,7 +225,7 @@ function _maybeLogEventLoopDelay(activeJobs) { upStr = ` active-by-hoster={${byHoster}} transient-errs=${d.transientErrors || 0} pending=${d.pending || 0}`; } } catch {} - logInfo('perf', `eventloop-delay active=${activeJobs} mean=${mean}ms p99=${p99}ms max=${max}ms stddev=${stddev}ms threadpool=${process.env.UV_THREADPOOL_SIZE}${cpuStr}${resStr}${upStr}`); + logInfo(`eventloop-delay active=${activeJobs} mean=${mean}ms p99=${p99}ms max=${max}ms stddev=${stddev}ms threadpool=${process.env.UV_THREADPOOL_SIZE}${cpuStr}${resStr}${upStr}`); _eventLoopDelay.reset(); } catch {} } @@ -1220,20 +1220,36 @@ function createWindow() { } function createTray() { - const iconPath = path.join(__dirname, 'assets', 'app_icon.ico'); - tray = new Tray(iconPath); - tray.setToolTip('Multi-Hoster-Upload'); + try { + const candidates = [ + path.join(process.resourcesPath || __dirname, 'assets', 'app_icon.ico'), + path.join(__dirname, 'assets', 'app_icon.ico'), + path.join(__dirname, 'assets', 'icon.png') + ]; + let icon = null; + for (const p of candidates) { + try { + const img = nativeImage.createFromPath(p); + if (img && !img.isEmpty()) { icon = img; break; } + } catch {} + } + tray = new Tray(icon || nativeImage.createEmpty()); + tray.setToolTip('Multi-Hoster-Upload'); - const contextMenu = Menu.buildFromTemplate([ - { label: 'Öffnen', click: () => { if (mainWindow) { mainWindow.show(); mainWindow.focus(); } } }, - { type: 'separator' }, - { label: 'Beenden', click: () => { app.quit(); } } - ]); - tray.setContextMenu(contextMenu); + const contextMenu = Menu.buildFromTemplate([ + { label: 'Öffnen', click: () => { if (mainWindow) { mainWindow.show(); mainWindow.focus(); } } }, + { type: 'separator' }, + { label: 'Beenden', click: () => { app.quit(); } } + ]); + tray.setContextMenu(contextMenu); - tray.on('click', () => { - if (mainWindow) { mainWindow.show(); mainWindow.focus(); } - }); + tray.on('click', () => { + if (mainWindow) { mainWindow.show(); mainWindow.focus(); } + }); + } catch (err) { + tray = null; + debugLog(`createTray failed (non-fatal): ${err && err.message ? err.message : err}`); + } } function updateTrayTooltip(text) { diff --git a/package.json b/package.json index ae87b87..1d98cac 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,9 @@ "main.js", "preload.js", "lib/**/*", - "renderer/**/*" + "renderer/**/*", + "assets/app_icon.ico", + "assets/app_icon.png" ], "win": { "target": [