From 98dfcbb3ce34440eb0df658de720b9beae128252 Mon Sep 17 00:00:00 2001 From: MKStoler1024 <158786854+MKStoler1024@users.noreply.github.com> Date: Wed, 15 Jan 2025 03:47:25 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B6=88=E9=99=A4=E8=80=83=E5=AE=8C?= =?UTF-8?q?=E4=B9=8B=E5=90=8E=E7=9A=84=E7=BA=A2=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- exam_config.json | 4 ++-- script.js | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/exam_config.json b/exam_config.json index 13a561d..b7a0525 100644 --- a/exam_config.json +++ b/exam_config.json @@ -1,7 +1,7 @@ { - "examName": "2024-2025学年度第一学期期末学业水平测试", + "examName": "2024-2025学年度第一学期高二教学质量检测", "message": "沉着考试,冷静应对", - "room": "08", + "room": " ", "examInfos": [ { "name": "语文", diff --git a/script.js b/script.js index 663ea2d..7b804f7 100644 --- a/script.js +++ b/script.js @@ -74,18 +74,18 @@ document.addEventListener("DOMContentLoaded", () => { if (currentExam) { currentSubjectElem.textContent = `当前科目: ${currentExam.name}`; examTimingElem.textContent = `起止时间: ${formatTimeWithoutSeconds(new Date(currentExam.start).toLocaleTimeString('zh-CN', { hour12: false }))} - ${formatTimeWithoutSeconds(new Date(currentExam.end).toLocaleTimeString('zh-CN', { hour12: false }))}`; - const remainingTime = (new Date(currentExam.end) - now) / 1000; + const remainingTime = (new Date(currentExam.end).getTime() - now.getTime()) / 1000; const remainingHours = Math.floor(remainingTime / 3600); const remainingMinutes = Math.floor((remainingTime % 3600) / 60); const remainingSeconds = Math.floor(remainingTime % 60); const remainingTimeText = `剩余时间: ${remainingHours}时 ${remainingMinutes}分 ${remainingSeconds}秒`; if (remainingHours === 0 && remainingMinutes <= 14) { - remainingTimeElem.textContent = remainingTimeText; + remainingTimeElem.textContent = `倒计时:` & remainingTimeText; remainingTimeElem.style.color = "red"; remainingTimeElem.style.fontWeight = "bold"; } else { - remainingTimeElem.textContent = remainingTimeText; + remainingTimeElem.textContent = `剩余时间:` & remainingTimeText; remainingTimeElem.style.color = "#93b4f7"; remainingTimeElem.style.fontWeight = "normal"; } @@ -95,11 +95,12 @@ document.addEventListener("DOMContentLoaded", () => { } else if (nextExam) { currentSubjectElem.textContent = `下一场科目: ${nextExam.name}`; 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.textContent = "当前无考试"; + remainingTimeElem.style.color = "#93b4f7"; statusElem.textContent = "状态: 未开始"; statusElem.style.color = "orange"; } else { - currentSubjectElem.textContent = "当前无考试"; + currentSubjectElem.textContent = "考试均已结束"; examTimingElem.textContent = ""; remainingTimeElem.textContent = ""; statusElem.textContent = "状态: 空闲";