feat: 添加任务超时提示 (#12430)

* test: 添加 block 任务

* feat: 添加任务超时提醒

* feat: 外部通知添加超时提醒

* chore: 提示时间改为四舍五入

* chore: 外部通知额外输入最后五条日志

* chore: 调整日志输出日期
This commit is contained in:
uye
2025-04-24 09:54:40 +08:00
committed by GitHub
parent f5b8fe18e1
commit 0cab88a1fb
15 changed files with 244 additions and 25 deletions

View File

@@ -29,6 +29,7 @@ using MaaWpfGui.Main;
using MaaWpfGui.Models;
using MaaWpfGui.Models.AsstTasks;
using MaaWpfGui.Services;
using MaaWpfGui.Services.Notification;
using MaaWpfGui.States;
using MaaWpfGui.Utilities;
using MaaWpfGui.Utilities.ValueType;
@@ -316,6 +317,7 @@ namespace MaaWpfGui.ViewModels.UI
_container = container;
_runningState = RunningState.Instance;
_runningState.IdleChanged += RunningState_IdleChanged;
_runningState.TimeoutOccurred += RunningState_TimeOut;
}
private void RunningState_IdleChanged(object sender, bool e)
@@ -328,6 +330,24 @@ namespace MaaWpfGui.ViewModels.UI
}
}
private void RunningState_TimeOut(object sender, string message)
{
Execute.OnUIThread(() =>
{
AddLog(message, UiLogColor.Warning);
ToastNotification.ShowDirect(message);
if (!SettingsViewModel.ExternalNotificationSettings.ExternalNotificationSendWhenTimeout)
{
return;
}
var lastLogs = LogItemViewModels
.TakeLast(5)
.Aggregate(string.Empty, (current, logItem) => current + $"[{logItem.Time}][{logItem.Color}]{logItem.Content}\n");
ExternalNotificationService.Send(message, lastLogs);
});
}
protected override void OnInitialActivate()
{
base.OnInitialActivate();