From 00e5c1eb9f5a02e1a9fdb6eef10b9ea1ea692c36 Mon Sep 17 00:00:00 2001 From: uye <99072975+ABA2396@users.noreply.github.com> Date: Mon, 15 Sep 2025 00:26:30 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E8=87=AA=E5=AE=9A=E4=B9=89=E5=9F=BA?= =?UTF-8?q?=E5=BB=BA=E9=85=8D=E7=BD=AE=E6=97=B6=E9=97=B4=E4=BB=8D=E5=9C=A8?= =?UTF-8?q?=E6=9C=89=E6=95=88=E6=9C=9F=E5=86=85=E6=97=B6=E4=B8=8D=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E5=85=B6=E4=BB=96=E6=97=B6=E9=97=B4=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InfrastSettingsUserControlModel.cs | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/InfrastSettingsUserControlModel.cs b/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/InfrastSettingsUserControlModel.cs index 0d5d73c24c..ac13bb5a96 100644 --- a/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/InfrastSettingsUserControlModel.cs +++ b/src/MaaWpfGui/ViewModels/UserControl/TaskQueue/InfrastSettingsUserControlModel.cs @@ -605,6 +605,22 @@ public class InfrastSettingsUserControlModel : TaskViewModel } var now = DateTime.Now; + + if (CustomInfrastPlanIndex >= CustomInfrastPlanInfoList.Count || CustomInfrastPlanIndex < 0) + { + CustomInfrastPlanIndex = 0; + } + + var currentPlan = CustomInfrastPlanInfoList.First(p => p.Index == CustomInfrastPlanIndex); + foreach (var period in currentPlan.PeriodList) + { + if (TimeLess(period.BeginHour, period.BeginMinute, now.Hour, now.Minute) && + TimeLess(now.Hour, now.Minute, period.EndHour, period.EndMinute)) + { + return; // 当前 index 仍在有效时间内,不需要切换 + } + } + foreach (var plan in CustomInfrastPlanInfoList.Where( plan => plan.PeriodList.Any( period => TimeLess(period.BeginHour, period.BeginMinute, now.Hour, now.Minute) && @@ -614,11 +630,6 @@ public class InfrastSettingsUserControlModel : TaskViewModel return; } - if (CustomInfrastPlanIndex >= CustomInfrastPlanList.Count || CustomInfrastPlanList.Count < 0) - { - CustomInfrastPlanIndex = 0; - } - return; static bool TimeLess(int lHour, int lMin, int rHour, int rMin) => (lHour != rHour) ? (lHour < rHour) : (lMin <= rMin);