From 2e59fd86ff1cf044c0c4adbcc696409ddc403f1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9C=E8=99=9E=E6=B8=A0=E6=88=90=E2=80=9D?= <“yuqucheng2006@qq.com”> Date: Mon, 29 Jun 2026 14:40:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=E5=AE=9A=E6=97=B6=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UI/Pages/HomePage/HomePageSchedule.cs | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/Assets/Scripts/UI/Pages/HomePage/HomePageSchedule.cs b/Assets/Scripts/UI/Pages/HomePage/HomePageSchedule.cs index d9e574e..73b6f5e 100644 --- a/Assets/Scripts/UI/Pages/HomePage/HomePageSchedule.cs +++ b/Assets/Scripts/UI/Pages/HomePage/HomePageSchedule.cs @@ -57,7 +57,7 @@ namespace Kill.UI.Pages } /// - /// 查找今天启用的任务(返回最近的一个未开始任务,排除进行中任务) + /// 查找今天启用的任务(返回最近的一个未结束任务) /// private ScheduleTask? FindTodayTask(byte todayFlag) { @@ -83,17 +83,19 @@ namespace Kill.UI.Pages continue; int taskTime = task.StartHour * 60 + task.StartMinute; + int endTime = task.EndHour * 60 + task.EndMinute; - // 只保留未开始的任务 - if (currentTime >= taskTime) + // 跳过已结束的任务 + if (currentTime >= endTime) continue; int timeDiff = taskTime - currentTime; - // 找距离当前时间最近的未开始任务 - if (timeDiff < nearestTimeDiff) + // 找距离当前时间最近的任务(包括进行中的和未来未开始的) + int absTimeDiff = Math.Abs(timeDiff); + if (absTimeDiff < nearestTimeDiff) { - nearestTimeDiff = timeDiff; + nearestTimeDiff = absTimeDiff; nearestTask = task; } } @@ -109,10 +111,23 @@ namespace Kill.UI.Pages string modeText = GetModeText(task.Mode); string timeText = $"{task.StartHour:D2}:{task.StartMinute:D2}"; + // 判断任务是未来还是进行中 + int currentTime = DateTime.Now.Hour * 60 + DateTime.Now.Minute; + int taskTime = task.StartHour * 60 + task.StartMinute; + bool isFutureTask = taskTime > currentTime; + if (scheduleText != null) { - // 经过 FindTodayTask 筛选后,只可能是未开始的任务 - scheduleText.text = $"{modeText}: {timeText}"; + if (isFutureTask) + { + // 即将开始的任务 + scheduleText.text = $"{modeText}: {timeText}"; + } + else + { + // 任务进行中,显示时间段 + scheduleText.text = $"{modeText}: {timeText}~{task.EndHour:D2}:{task.EndMinute:D2}"; + } } }