From faac8bac27a5be2264e99206d5f63f9b0dcf47aa Mon Sep 17 00:00:00 2001 From: Jursin <1836059252@qq.com> Date: Sun, 1 Dec 2024 13:26:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20SubjectInfo.vue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/src/components/SubjectInfo.vue | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/renderer/src/components/SubjectInfo.vue b/src/renderer/src/components/SubjectInfo.vue index cf38c8d..949ad1b 100644 --- a/src/renderer/src/components/SubjectInfo.vue +++ b/src/renderer/src/components/SubjectInfo.vue @@ -11,7 +11,6 @@ 考试状态: {{ statusText }}
开考倒计时: {{ countdown }}
-
考试即将结束
考试剩余时间: {{ remainingTime }}
@@ -64,15 +63,6 @@ const statusText = computed(() => { if (now.value >= end) return '已结束'; }); -const isWarning = computed(() => { - if (!props.exam) return false; - - const end = new Date(props.exam.end); - const fifteenMinutesBeforeEnd = new Date(end.getTime() - 15 * 60 * 1000); - - return now.value >= fifteenMinutesBeforeEnd && now.value < end; -}); - const showRemainingTime = computed(() => { if (!props.exam) return false; @@ -114,7 +104,14 @@ const countdown = computed(() => { }); // 动态颜色样式 -const remainingTimeColorClass = computed(() => (isWarning.value ? 'text--warning' : 'text--default')); +const remainingTimeColorClass = computed(() => { + if (!props.exam) return 'text--default'; + + const end = new Date(props.exam.end); + const fifteenMinutesBeforeEnd = new Date(end.getTime() - 15 * 60 * 1000); + + return now.value >= fifteenMinutesBeforeEnd && now.value < end ? 'text--warning' : 'text--default'; +}); // Update the current time every second const updateNow = () => { @@ -169,4 +166,4 @@ updateNow(); .text-center { text-align: center; } - + \ No newline at end of file