fix: 修复订阅窗口过期后进度条显示不正确的问题
问题:滑动窗口过期后(如昨天用满额度),前端仍显示历史数据(红色进度条100%、"即将重置") 解决: - 后端返回数据前检查窗口是否过期,过期则清零展示数据 - 前端处理 window_start 为 null 的情况,显示"窗口未激活" - 不影响实际的窗口激活逻辑,窗口仍从当天零点开始
This commit is contained in:
@@ -582,6 +582,7 @@ export default {
|
||||
monthly: 'Monthly',
|
||||
noLimits: 'No limits configured',
|
||||
resetNow: 'Resetting soon',
|
||||
windowNotActive: 'Window not active',
|
||||
resetInMinutes: 'Resets in {minutes}m',
|
||||
resetInHoursMinutes: 'Resets in {hours}h {minutes}m',
|
||||
resetInDaysHours: 'Resets in {days}d {hours}h',
|
||||
@@ -1121,6 +1122,7 @@ export default {
|
||||
daysRemaining: '{days} days remaining',
|
||||
expiresOn: 'Expires on {date}',
|
||||
resetIn: 'Resets in {time}',
|
||||
windowNotActive: 'Awaiting first use',
|
||||
usageOf: '{used} of {limit}',
|
||||
},
|
||||
}
|
||||
|
||||
@@ -639,6 +639,7 @@ export default {
|
||||
monthly: '每月',
|
||||
noLimits: '未配置限额',
|
||||
resetNow: '即将重置',
|
||||
windowNotActive: '窗口未激活',
|
||||
resetInMinutes: '{minutes} 分钟后重置',
|
||||
resetInHoursMinutes: '{hours} 小时 {minutes} 分钟后重置',
|
||||
resetInDaysHours: '{days} 天 {hours} 小时后重置',
|
||||
@@ -1302,6 +1303,7 @@ export default {
|
||||
daysRemaining: '剩余 {days} 天',
|
||||
expiresOn: '{date} 到期',
|
||||
resetIn: '{time} 后重置',
|
||||
windowNotActive: '等待首次使用',
|
||||
usageOf: '已用 {used} / {limit}',
|
||||
},
|
||||
}
|
||||
|
||||
@@ -592,6 +592,8 @@ const getProgressClass = (used: number, limit: number | null): string => {
|
||||
|
||||
// Format reset time based on window start and period type
|
||||
const formatResetTime = (windowStart: string, period: 'daily' | 'weekly' | 'monthly'): string => {
|
||||
if (!windowStart) return t('admin.subscriptions.windowNotActive')
|
||||
|
||||
const start = new Date(windowStart)
|
||||
const now = new Date()
|
||||
|
||||
@@ -610,7 +612,7 @@ const formatResetTime = (windowStart: string, period: 'daily' | 'weekly' | 'mont
|
||||
}
|
||||
|
||||
const diffMs = resetTime.getTime() - now.getTime()
|
||||
if (diffMs <= 0) return t('admin.subscriptions.resetNow')
|
||||
if (diffMs <= 0) return t('admin.subscriptions.windowNotActive')
|
||||
|
||||
const diffSeconds = Math.floor(diffMs / 1000)
|
||||
const days = Math.floor(diffSeconds / 86400)
|
||||
|
||||
@@ -229,14 +229,14 @@ function getExpirationClass(expiresAt: string): string {
|
||||
}
|
||||
|
||||
function formatResetTime(windowStart: string | null, windowHours: number): string {
|
||||
if (!windowStart) return '--';
|
||||
if (!windowStart) return t('userSubscriptions.windowNotActive');
|
||||
|
||||
const start = new Date(windowStart);
|
||||
const end = new Date(start.getTime() + windowHours * 60 * 60 * 1000);
|
||||
const now = new Date();
|
||||
const diff = end.getTime() - now.getTime();
|
||||
|
||||
if (diff <= 0) return 'Now';
|
||||
if (diff <= 0) return t('userSubscriptions.windowNotActive');
|
||||
|
||||
const hours = Math.floor(diff / (1000 * 60 * 60));
|
||||
const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60));
|
||||
|
||||
Reference in New Issue
Block a user