feat: send external notification when all tasks are finished

This commit is contained in:
Liam Sho
2023-09-12 21:37:48 +08:00
parent 9f20fe9241
commit 9e9745ebda
2 changed files with 13 additions and 1 deletions

View File

@@ -27,6 +27,7 @@ using HandyControl.Tools.Extension;
using MaaWpfGui.Constants;
using MaaWpfGui.Extensions;
using MaaWpfGui.Helper;
using MaaWpfGui.Services.Notification;
using MaaWpfGui.States;
using MaaWpfGui.ViewModels.UI;
using Newtonsoft.Json;
@@ -613,7 +614,17 @@ namespace MaaWpfGui.Main
if (isMainTaskQueueAllCompleted)
{
Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("AllTasksComplete"));
using (var toast = new ToastNotification(LocalizationHelper.GetString("AllTasksComplete")))
var allTaskCompleteTitle = LocalizationHelper.GetString("AllTasksComplete");
var allTaskCompleteMessage = LocalizationHelper.GetString("AllTaskCompleteContent");
var configurationPreset = ConfigurationHelper.GetValue(ConfigurationKeys.CurrentConfiguration, "Default");
allTaskCompleteMessage = allTaskCompleteMessage
.Replace("{Datetime}", DateTime.Now.ToString("U"))
.Replace("{Preset}", configurationPreset);
ExternalNotificationService.SendAsync(allTaskCompleteTitle, allTaskCompleteMessage).Wait();
using (var toast = new ToastNotification(allTaskCompleteTitle))
{
toast.Show();
}

View File

@@ -526,6 +526,7 @@
<system:String x:Key="StartCombat" xml:space="preserve">开始战斗: </system:String>
<system:String x:Key="CompleteCombat">完成战斗</system:String>
<system:String x:Key="AllTasksComplete">任务已全部完成!</system:String>
<system:String x:Key="AllTaskCompleteContent">MAA 已在 {Datetime} 完成了 {Preset} 配置下所有预设的任务。</system:String>
<system:String x:Key="BackgroundLinkStarted">开始执行任务</system:String>
<system:String x:Key="BackgroundLinkStopped">任务终止</system:String>
<system:String x:Key="FailedToOpenClient">打开客户端失败,请检查配置文件</system:String>