From 26345cfce446ffe7fb717d42f4fe0fa9a7d57217 Mon Sep 17 00:00:00 2001 From: MKStoler1024 <158786854+MKStoler1024@users.noreply.github.com> Date: Fri, 17 Jan 2025 03:46:46 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0=E5=80=92=E8=AE=A1?= =?UTF-8?q?=E6=97=B6=E5=92=8C=E7=8A=B6=E6=80=81=E6=96=87=E6=9C=AC=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8D=B3=E5=B0=86=E5=BC=80=E5=A7=8B=E7=9A=84?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- exam/script.js | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/exam/script.js b/exam/script.js index 339e3ec..8ddff53 100644 --- a/exam/script.js +++ b/exam/script.js @@ -86,7 +86,7 @@ document.addEventListener("DOMContentLoaded", () => { remainingTimeElem.style.color = "red"; remainingTimeElem.style.fontWeight = "bold"; } else { - remainingTimeElem.textContent = `剩余时: ${remainingTimeText}`; + remainingTimeElem.textContent = `剩余时间: ${remainingTimeText}`; remainingTimeElem.style.color = "#93b4f7"; remainingTimeElem.style.fontWeight = "normal"; } @@ -94,13 +94,28 @@ document.addEventListener("DOMContentLoaded", () => { statusElem.textContent = "状态: 进行中"; statusElem.style.color = "#5ba838"; } else if (nextExam) { - currentSubjectElem.textContent = `下一场科目: ${nextExam.name}`; + const timeUntilStart = ((new Date(nextExam.start).getTime() - now.getTime()) / 1000) + 1; + const remainingHours = Math.floor(timeUntilStart / 3600); + const remainingMinutes = Math.floor((timeUntilStart % 3600) / 60); + const remainingSeconds = Math.floor(timeUntilStart % 60); + const remainingTimeText = `${remainingHours}时 ${remainingMinutes}分 ${remainingSeconds}秒`; + + if (timeUntilStart <= 15 * 60) { + currentSubjectElem.textContent = `即将开始: ${nextExam.name}`; + remainingTimeElem.textContent = `倒计时: ${remainingTimeText}`; + remainingTimeElem.style.color = "orange"; + remainingTimeElem.style.fontWeight = "bold"; + statusElem.textContent = "状态: 即将开始"; + statusElem.style.color = "#DBA014"; + } else { + currentSubjectElem.textContent = `下一场科目: ${nextExam.name}`; + remainingTimeElem.textContent = ""; + statusElem.textContent = "状态: 未开始"; + remainingTimeElem.style.fontWeight = "normal"; + statusElem.style.color = "#EAEE5B"; + } + examTimingElem.textContent = `起止时间: ${formatTimeWithoutSeconds(new Date(nextExam.start).toLocaleTimeString('zh-CN', { hour12: false }))} - ${formatTimeWithoutSeconds(new Date(nextExam.end).toLocaleTimeString('zh-CN', { hour12: false }))}`; - remainingTimeElem.textContent = "当前无考试"; - remainingTimeElem.style.color = "#93b4f7"; - statusElem.textContent = "状态: 未开始"; - statusElem.style.fontWeight = "normal"; - statusElem.style.color = "orange"; } else { currentSubjectElem.textContent = "考试均已结束"; examTimingElem.textContent = "";