mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-19 18:47:55 +08:00
feat: 添加任务超时提示 (#12430)
* test: 添加 block 任务 * feat: 添加任务超时提醒 * feat: 外部通知添加超时提醒 * chore: 提示时间改为四舍五入 * chore: 外部通知额外输入最后五条日志 * chore: 调整日志输出日期
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user