diff --git a/frontend/src/views/Home.vue b/frontend/src/views/Home.vue index 17651de..236ee0e 100644 --- a/frontend/src/views/Home.vue +++ b/frontend/src/views/Home.vue @@ -62,9 +62,23 @@
+ + + { } } -// 检查剩余时间是否小于两天 -const isLessThanTwoDays = (expireTime: string) => { +// 检查剩余时间状态:normal(>2天)、warning(<=2天>0)、ended(<=0) +const getActivityTimeStatus = (expireTime: string): 'normal' | 'warning' | 'ended' => { try { const expire = new Date(expireTime) const now = new Date() const remaining = expire.getTime() - now.getTime() const twoDaysInMs = 2 * 24 * 60 * 60 * 1000 - return remaining <= twoDaysInMs + if (remaining <= 0) return 'ended' + if (remaining <= twoDaysInMs) return 'warning' + return 'normal' } catch { - return false + return 'ended' } }