Skip to content

Commit b9ba162

Browse files
committed
Fixed bug: Electron tray icon TypeError
1 parent ad399f5 commit b9ba162

File tree

5 files changed

+27
-7
lines changed

5 files changed

+27
-7
lines changed

Changelog.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Not released
22

3+
# 5.22.14
4+
5+
ElectronNET.CLI:
6+
7+
* Fixed bug: Electron tray icon TypeError ([Electron original issue](https://github.com/electron/electron/issues/7657))
8+
* Fixed bug: Wrong tray icon path in the application built via `electronize build` command
9+
10+
ElectronNET.WebApp:
11+
12+
* Fixed usage of the `Electron.Tray.Show` according fixed bugs in the ElectronNET.CLI
13+
314

415
# Released
516

ElectronNET.Host/api/tray.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ElectronNET.Host/api/tray.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ export = (socket: SocketIO.Socket) => {
6060
electronSocket.emit('trayMenuItemClicked', id);
6161
});
6262

63-
const imagePath = path.join(__dirname.replace('api', ''), 'bin', image);
63+
const trayIcon = nativeImage.createFromPath(image);
6464

65-
tray = new Tray(imagePath);
65+
tray = new Tray(trayIcon);
6666
tray.setContextMenu(menu);
6767
});
6868

ElectronNET.WebApp/Controllers/TrayController.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1-
using Microsoft.AspNetCore.Mvc;
1+
using System.IO;
2+
using Microsoft.AspNetCore.Mvc;
23
using ElectronNET.API;
34
using ElectronNET.API.Entities;
5+
using Microsoft.AspNetCore.Hosting;
46

57
namespace ElectronNET.WebApp.Controllers
68
{
79
public class TrayController : Controller
810
{
11+
private readonly IHostingEnvironment _env;
12+
13+
public TrayController(IHostingEnvironment env)
14+
{
15+
_env = env;
16+
}
17+
18+
919
public IActionResult Index()
1020
{
1121
if (HybridSupport.IsElectronActive)
@@ -21,7 +31,7 @@ public IActionResult Index()
2131
Click = () => Electron.Tray.Destroy()
2232
};
2333

24-
Electron.Tray.Show("/Assets/electron_32x32.png", menu);
34+
Electron.Tray.Show(Path.Combine(_env.ContentRootPath, "Assets/electron_32x32.png"), menu);
2535
Electron.Tray.SetToolTip("Electron Demo in the tray.");
2636
}
2737
else

ElectronNET.WebApp/ElectronNET.WebApp.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
<Content Remove="Views\Windows\HandleErrorCrashes.cshtml" />
1212
</ItemGroup>
1313
<ItemGroup>
14-
<Folder Include="Assets\" />
1514
<Folder Include="wwwroot\assets\" />
1615
</ItemGroup>
1716
<ItemGroup>

0 commit comments

Comments
 (0)