diff --git a/BetterGenshinImpact/App.xaml.cs b/BetterGenshinImpact/App.xaml.cs
index 8b5fb7dc..24a268b6 100644
--- a/BetterGenshinImpact/App.xaml.cs
+++ b/BetterGenshinImpact/App.xaml.cs
@@ -185,6 +185,8 @@ public partial class App : Application
protected override async void OnExit(ExitEventArgs e)
{
base.OnExit(e);
+
+ TempManager.CleanUp();
await _host.StopAsync();
_host.Dispose();
diff --git a/BetterGenshinImpact/BetterGenshinImpact.csproj b/BetterGenshinImpact/BetterGenshinImpact.csproj
index 9e81a682..b138ab2d 100644
--- a/BetterGenshinImpact/BetterGenshinImpact.csproj
+++ b/BetterGenshinImpact/BetterGenshinImpact.csproj
@@ -47,6 +47,7 @@
+
diff --git a/BetterGenshinImpact/Helpers/TempManager.cs b/BetterGenshinImpact/Helpers/TempManager.cs
new file mode 100644
index 00000000..25ae16f2
--- /dev/null
+++ b/BetterGenshinImpact/Helpers/TempManager.cs
@@ -0,0 +1,26 @@
+using System;
+using System.IO;
+using BetterGenshinImpact.Core.Config;
+
+namespace BetterGenshinImpact.Helpers;
+
+public class TempManager
+{
+ public static readonly string TempDirectory = Global.Absolute("User/Temp");
+ static TempManager()
+ {
+ Directory.CreateDirectory(TempDirectory);
+ }
+
+ public static void CleanUp()
+ {
+ try
+ {
+ DirectoryHelper.DeleteDirectoryRecursively(TempDirectory);
+ }
+ catch
+ {
+ // Suppress any exceptions to avoid exposing errors
+ }
+ }
+}
\ No newline at end of file
diff --git a/BetterGenshinImpact/Service/Notification/NotificationConfig.cs b/BetterGenshinImpact/Service/Notification/NotificationConfig.cs
index f8826963..1da20fe9 100644
--- a/BetterGenshinImpact/Service/Notification/NotificationConfig.cs
+++ b/BetterGenshinImpact/Service/Notification/NotificationConfig.cs
@@ -26,4 +26,11 @@ public partial class NotificationConfig : ObservableObject
///
[ObservableProperty]
private bool _includeScreenShot = false;
+
+ ///
+ /// windows uwp 通知是否启用
+ ///
+ [ObservableProperty]
+ private bool _windowsUwpNotificationEnabled = false;
+
}
diff --git a/BetterGenshinImpact/Service/Notification/NotificationService.cs b/BetterGenshinImpact/Service/Notification/NotificationService.cs
index 4e62ce91..98942c0f 100644
--- a/BetterGenshinImpact/Service/Notification/NotificationService.cs
+++ b/BetterGenshinImpact/Service/Notification/NotificationService.cs
@@ -6,11 +6,13 @@ using BetterGenshinImpact.Service.Notifier.Exception;
using BetterGenshinImpact.Service.Notifier.Interface;
using Microsoft.Extensions.Hosting;
using System;
+using System.Drawing;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
+using System.Windows.Media.Imaging;
using BetterGenshinImpact.GameTask;
using BetterGenshinImpact.Service.Notification.Model.Enum;
@@ -56,6 +58,10 @@ public class NotificationService : IHostedService
{
_notifierManager.RegisterNotifier(new WebhookNotifier(NotifyHttpClient, TaskContext.Instance().Config.NotificationConfig.WebhookEndpoint));
}
+ if (TaskContext.Instance().Config.NotificationConfig.WindowsUwpNotificationEnabled)
+ {
+ _notifierManager.RegisterNotifier(new WindowsUwpNotifier());
+ }
}
public void RefreshNotifiers()
@@ -73,12 +79,13 @@ public class NotificationService : IHostedService
{
return NotificationTestResult.Error("通知类型未启用");
}
- await notifier.SendNotificationAsync(new TestNotificationData
+ await notifier.SendAsync(new TestNotificationData
{
Event = NotificationEvent.Test,
Action = NotificationAction.Started,
Conclusion = NotificationConclusion.Success,
- Message = "测试通知"
+ Message = "测试通知",
+ // Screenshot =
});
return NotificationTestResult.Success();
}
diff --git a/BetterGenshinImpact/Service/Notifier/Interface/INotifier.cs b/BetterGenshinImpact/Service/Notifier/Interface/INotifier.cs
index b705cdd5..d4023bc3 100644
--- a/BetterGenshinImpact/Service/Notifier/Interface/INotifier.cs
+++ b/BetterGenshinImpact/Service/Notifier/Interface/INotifier.cs
@@ -8,5 +8,5 @@ public interface INotifier
{
string Name { get; }
- Task SendNotificationAsync(INotificationData content);
+ Task SendAsync(INotificationData data);
}
diff --git a/BetterGenshinImpact/Service/Notifier/NotifierManager.cs b/BetterGenshinImpact/Service/Notifier/NotifierManager.cs
index da1a344c..17e4e42a 100644
--- a/BetterGenshinImpact/Service/Notifier/NotifierManager.cs
+++ b/BetterGenshinImpact/Service/Notifier/NotifierManager.cs
@@ -41,7 +41,7 @@ public class NotifierManager
{
try
{
- await notifier.SendNotificationAsync(content);
+ await notifier.SendAsync(content);
}
catch (System.Exception ex)
{
diff --git a/BetterGenshinImpact/Service/Notifier/WebhookNotifier.cs b/BetterGenshinImpact/Service/Notifier/WebhookNotifier.cs
index 93f73a90..8600dcf4 100644
--- a/BetterGenshinImpact/Service/Notifier/WebhookNotifier.cs
+++ b/BetterGenshinImpact/Service/Notifier/WebhookNotifier.cs
@@ -15,6 +15,11 @@ public class WebhookNotifier : INotifier
public string Endpoint { get; set; }
private readonly HttpClient _httpClient;
+
+ private readonly JsonSerializerOptions _jsonSerializerOptions = new()
+ {
+ PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower,
+ };
public WebhookNotifier(HttpClient httpClient, string endpoint = "")
{
@@ -22,7 +27,7 @@ public class WebhookNotifier : INotifier
Endpoint = endpoint;
}
- public async Task SendNotificationAsync(INotificationData content)
+ public async Task SendAsync(INotificationData content)
{
try
{
@@ -47,10 +52,7 @@ public class WebhookNotifier : INotifier
private StringContent TransformData(INotificationData notificationData)
{
// using object type here so it serializes the interface correctly
- var serializedData = JsonSerializer.Serialize