mirror of
https://github.com/ExamAware/ExamSchedule.git
synced 2025-04-29 11:06:32 +00:00
fix: 增加对上场考试状态的处理,显示已结束的考试信息
This commit is contained in:
parent
26345cfce4
commit
d1a5e5c6d8
@ -60,6 +60,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
const now = new Date(new Date().getTime() + offsetTime * 1000);
|
||||
let currentExam = null;
|
||||
let nextExam = null;
|
||||
let lastExam = null;
|
||||
|
||||
data.examInfos.forEach(exam => {
|
||||
const start = new Date(exam.start);
|
||||
@ -70,6 +71,9 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
if (!currentExam && !nextExam && now < start) {
|
||||
nextExam = exam;
|
||||
}
|
||||
if (now > end && (!lastExam || end > new Date(lastExam.end))) {
|
||||
lastExam = exam;
|
||||
}
|
||||
});
|
||||
|
||||
if (currentExam) {
|
||||
@ -93,6 +97,13 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
|
||||
statusElem.textContent = "状态: 进行中";
|
||||
statusElem.style.color = "#5ba838";
|
||||
} else if (lastExam && now < new Date(lastExam.end).getTime() + 60000) {
|
||||
const timeSinceEnd = (now.getTime() - new Date(lastExam.end).getTime()) / 1000;
|
||||
currentSubjectElem.textContent = `上场科目: ${lastExam.name}`;
|
||||
examTimingElem.textContent = "";
|
||||
remainingTimeElem.textContent = ``;
|
||||
statusElem.textContent = "状态: 已结束";
|
||||
statusElem.style.color = "red";
|
||||
} else if (nextExam) {
|
||||
const timeUntilStart = ((new Date(nextExam.start).getTime() - now.getTime()) / 1000) + 1;
|
||||
const remainingHours = Math.floor(timeUntilStart / 3600);
|
||||
|
Loading…
x
Reference in New Issue
Block a user