perf: 仅在LinkStart时执行完成后动作, 避免单次运行时触发

This commit is contained in:
status102
2026-05-30 17:45:29 +08:00
parent 7d6ad3b4c1
commit b3801e64ee
2 changed files with 14 additions and 3 deletions

View File

@@ -1176,6 +1176,8 @@ public class AsstProxy
case AsstMsg.AllTasksCompleted:
bool isMainTaskQueueAllCompleted = false;
bool startByLinkStart = Instances.TaskQueueViewModel.StartByLinkStart;
Instances.TaskQueueViewModel.StartByLinkStart = false;
var taskList = details["finished_tasks"]?.ToObject<AsstTaskId[]>();
if (taskList?.Length > 0)
{
@@ -1287,12 +1289,15 @@ public class AsstProxy
}
// Instances.TaskQueueViewModel.CheckAndShutdown();
_ = Instances.TaskQueueViewModel.CheckAfterCompleted();
if (Instances.OverlayViewModel.IsCreated)
{
AchievementTrackerHelper.Instance.Unlock(AchievementIds.LogSupervisor);
}
if (startByLinkStart)
{
_ = Instances.TaskQueueViewModel.CheckAfterCompleted();
}
}
else if (isCopilotTaskChain)
{

View File

@@ -29,7 +29,6 @@ using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
using JetBrains.Annotations;
using MaaWpfGui.Configuration;
using MaaWpfGui.Configuration.Factory;
using MaaWpfGui.Configuration.Single.MaaTask;
using MaaWpfGui.Constants;
@@ -212,6 +211,8 @@ public class TaskQueueViewModel : Screen
});
}
#region Overlay
public static void ChooseOverlayTarget()
{
try
@@ -275,6 +276,8 @@ public class TaskQueueViewModel : Screen
}
}
#endregion Overlay
/// <summary>
/// Gets or private sets the view models of log items.
/// </summary>
@@ -435,6 +438,8 @@ public class TaskQueueViewModel : Screen
#region ActionAfterTasks
public bool StartByLinkStart { get; set; }
private bool _enableAfterActionSetting;
/// <summary>
@@ -1769,6 +1774,7 @@ public class TaskQueueViewModel : Screen
/// <returns>Task</returns>
public async Task LinkStart()
{
StartByLinkStart = true;
using var log = new LogScope(_logger);
await TaskQueueSerializingLock.WaitAsync();
await LinkStartWithTasks(ConfigFactory.CurrentConfig.TaskQueue);