diff --git a/src/ST.Client.Desktop.Avalonia/ServiceCollectionExtensions.cs b/src/ST.Client.Desktop.Avalonia/ServiceCollectionExtensions.cs index d63f9a211..46073da54 100644 --- a/src/ST.Client.Desktop.Avalonia/ServiceCollectionExtensions.cs +++ b/src/ST.Client.Desktop.Avalonia/ServiceCollectionExtensions.cs @@ -28,17 +28,6 @@ namespace Microsoft.Extensions.DependencyInjection return services; } - /// - /// 添加适用于桌面端的 - /// - /// - /// - public static IServiceCollection AddNotificationService(this IServiceCollection services) - { - services.AddSingleton(); - return services; - } - public static IServiceCollection AddFontManager(this IServiceCollection services, bool useGdiPlusFirst) { services.AddSingleton(new AvaloniaFontManagerImpl(useGdiPlusFirst)); diff --git a/src/ST.Client.Desktop/ServiceCollectionExtensions.cs b/src/ST.Client.Desktop/ServiceCollectionExtensions.cs index 37883d8e7..f75b4d595 100644 --- a/src/ST.Client.Desktop/ServiceCollectionExtensions.cs +++ b/src/ST.Client.Desktop/ServiceCollectionExtensions.cs @@ -85,7 +85,7 @@ namespace Microsoft.Extensions.DependencyInjection } /// - /// 添加 Window 窗口viewmodel + /// 添加窗口服务 /// /// /// @@ -94,5 +94,16 @@ namespace Microsoft.Extensions.DependencyInjection services.AddSingleton(); return services; } + + /// + /// 添加适用于桌面端的 + /// + /// + /// + public static IServiceCollection AddNotificationService(this IServiceCollection services) + { + services.AddSingleton(); + return services; + } } } \ No newline at end of file diff --git a/src/ST.Client.Desktop.Avalonia/Application/Services/Implementation/PlatformNotificationServiceImpl.cs b/src/ST.Client.Desktop/Services/Implementation/PlatformNotificationServiceImpl.cs similarity index 74% rename from src/ST.Client.Desktop.Avalonia/Application/Services/Implementation/PlatformNotificationServiceImpl.cs rename to src/ST.Client.Desktop/Services/Implementation/PlatformNotificationServiceImpl.cs index 3086e7141..4269dd50f 100644 --- a/src/ST.Client.Desktop.Avalonia/Application/Services/Implementation/PlatformNotificationServiceImpl.cs +++ b/src/ST.Client.Desktop/Services/Implementation/PlatformNotificationServiceImpl.cs @@ -1,4 +1,3 @@ -using System.Application.UI; using System.Properties; using System.Windows; @@ -18,19 +17,28 @@ namespace System.Application.Services.Implementation void INotificationService.Cancel(NotificationType notificationType) { - notifyIcon.HideBalloonTip(); + if (OperatingSystem2.IsWindows) + { + notifyIcon.HideBalloonTip(); + } } void INotificationService.CancelAll() { - notifyIcon.HideBalloonTip(); + if (OperatingSystem2.IsWindows) + { + notifyIcon.HideBalloonTip(); + } } void INotificationService.Notify(string text, NotificationType notificationType, bool autoCancel, string? title, Entrance entrance) { - title ??= ThisAssembly.AssemblyTrademark; - // 调用托盘显示通知 - notifyIcon.ShowBalloonTip(title, text, ToolTipIcon.None); + if (OperatingSystem2.IsWindows) + { + title ??= ThisAssembly.AssemblyTrademark; + // 调用托盘显示通知 + notifyIcon.ShowBalloonTip(title, text, ToolTipIcon.None); + } } Progress INotificationService.NotifyDownload(Func text, NotificationType notificationType, string? title)