From b5f277500f777fdd6fc45bd30aa8a11d291ba3ac Mon Sep 17 00:00:00 2001 From: aaron <> Date: Mon, 27 Apr 2026 11:11:52 +0800 Subject: [PATCH] 1 --- frontend/src/app/(app)/dashboard/page.tsx | 49 +++++++++++++++++++---- 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/frontend/src/app/(app)/dashboard/page.tsx b/frontend/src/app/(app)/dashboard/page.tsx index 3a77bc9..7abbc5d 100644 --- a/frontend/src/app/(app)/dashboard/page.tsx +++ b/frontend/src/app/(app)/dashboard/page.tsx @@ -26,6 +26,8 @@ export default function DashboardPage() { const [selectedAnnouncement, setSelectedAnnouncement] = useState(null); const [selectedSchedule, setSelectedSchedule] = useState(null); const [now, setNow] = useState(() => Date.now()); + const getScheduleDisplayTime = (item: ScheduleItem) => + item.type === "deadline" && item.end_time ? item.end_time : item.start_time; useEffect(() => { if (!activeClassId) return; @@ -63,10 +65,10 @@ export default function DashboardPage() { const countdownByScheduleId = useMemo(() => { return Object.fromEntries( upcoming.map((item) => { - const diff = new Date(item.start_time).getTime() - now; + const diff = new Date(getScheduleDisplayTime(item)).getTime() - now; const days = Math.ceil(diff / (1000 * 60 * 60 * 24)); const label = - days <= 0 ? "已开始" : days === 1 ? "明天" : `${days}天后`; + days <= 0 ? "已截止" : days === 1 ? "明天" : `${days}天后`; return [item.id, label]; }) ); @@ -190,7 +192,7 @@ export default function DashboardPage() {

{item.title}

- {new Date(item.start_time).toLocaleDateString("zh-CN")} + {new Date(getScheduleDisplayTime(item)).toLocaleDateString("zh-CN")}

@@ -280,11 +282,44 @@ export default function DashboardPage() {
-

开始:{new Date(selectedSchedule.start_time).toLocaleString("zh-CN", { year: "numeric", month: "long", day: "numeric", hour: "2-digit", minute: "2-digit" })}

- {selectedSchedule.end_time && ( -

结束:{new Date(selectedSchedule.end_time).toLocaleString("zh-CN", { year: "numeric", month: "long", day: "numeric", hour: "2-digit", minute: "2-digit" })}

+ {selectedSchedule.type === "deadline" ? ( +

+ 截止时间: + {new Date(getScheduleDisplayTime(selectedSchedule)).toLocaleString("zh-CN", { + year: "numeric", + month: "long", + day: "numeric", + hour: "2-digit", + minute: "2-digit", + })} +

+ ) : ( + <> +

+ 开始: + {new Date(selectedSchedule.start_time).toLocaleString("zh-CN", { + year: "numeric", + month: "long", + day: "numeric", + hour: "2-digit", + minute: "2-digit", + })} +

+ {selectedSchedule.end_time && ( +

+ 结束: + {new Date(selectedSchedule.end_time).toLocaleString("zh-CN", { + year: "numeric", + month: "long", + day: "numeric", + hour: "2-digit", + minute: "2-digit", + })} +

+ )} + )} - {selectedSchedule.location && ( + {selectedSchedule.type !== "deadline" && selectedSchedule.location && (

地点:{selectedSchedule.location}

)}