mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-31 16:26:30 +00:00
Merge pull request #5078 from wucm667/fix/issue-5072-subscription-expiry-label
fix(frontend): correct subscription expiry labels
This commit is contained in:
@@ -259,7 +259,12 @@ import Icon from '@/components/icons/Icon.vue'
|
||||
import { formatDateTimeToMinute } from '@/utils/format'
|
||||
import { hasPeakRate, formatPeakRateWindow, serverTimezoneLabel } from '@/utils/peak-rate'
|
||||
import { platformBorderClass, platformBadgeClass, platformButtonClass, platformLabel } from '@/utils/platformColors'
|
||||
import { getRemainingDurationParts, isOneTimeDailyQuota, type RemainingDurationParts } from '@/utils/subscriptionQuota'
|
||||
import {
|
||||
getExpirationDateRelation,
|
||||
getRemainingDurationParts,
|
||||
isOneTimeDailyQuota,
|
||||
type RemainingDurationParts
|
||||
} from '@/utils/subscriptionQuota'
|
||||
|
||||
function platformAccentDotClass(p: string): string {
|
||||
switch (p) {
|
||||
@@ -317,17 +322,20 @@ function formatExpirationDate(expiresAt: string): string {
|
||||
const expires = new Date(expiresAt)
|
||||
const diff = expires.getTime() - now.getTime()
|
||||
const days = Math.ceil(diff / (1000 * 60 * 60 * 24))
|
||||
const relation = getExpirationDateRelation(expires, now)
|
||||
|
||||
if (days < 0) {
|
||||
if (relation === null) return ''
|
||||
|
||||
if (relation === 'expired') {
|
||||
return t('userSubscriptions.status.expired')
|
||||
}
|
||||
|
||||
const dateStr = formatDateTimeToMinute(expires)
|
||||
|
||||
if (days === 0) {
|
||||
if (relation === 'today') {
|
||||
return `${dateStr} (${t('common.today')})`
|
||||
}
|
||||
if (days === 1) {
|
||||
if (relation === 'tomorrow') {
|
||||
return `${dateStr} (${t('common.tomorrow')})`
|
||||
}
|
||||
|
||||
@@ -340,7 +348,7 @@ function getExpirationClass(expiresAt: string): string {
|
||||
const diff = expires.getTime() - now.getTime()
|
||||
const days = Math.ceil(diff / (1000 * 60 * 60 * 24))
|
||||
|
||||
if (days <= 0) return 'text-red-600 dark:text-red-400 font-medium'
|
||||
if (diff <= 0) return 'text-red-600 dark:text-red-400 font-medium'
|
||||
if (days <= 3) return 'text-red-600 dark:text-red-400'
|
||||
if (days <= 7) return 'text-orange-600 dark:text-orange-400'
|
||||
return 'text-gray-700 dark:text-gray-300'
|
||||
|
||||
Reference in New Issue
Block a user