Spaces:
Runtime error
Runtime error
Download web/src/helpers/subscriptionFormat.js from Tomsass1/test-docker: direct link, hf CLI and curl.
- Browser
- Download file 1.31 kB
-
https://huggingface.co/spaces/Tomsass1/test-docker/resolve/main/web/src/helpers/subscriptionFormat.js
- Command line
-
hf download hf://spaces/Tomsass1/test-docker/web/src/helpers/subscriptionFormat.js
-
curl -L -o subscriptionFormat.js https://huggingface.co/spaces/Tomsass1/test-docker/resolve/main/web/src/helpers/subscriptionFormat.js
1.31 kB
| export function formatSubscriptionDuration(plan, t) { | |
| const unit = plan?.duration_unit || 'month'; | |
| const value = plan?.duration_value || 1; | |
| const unitLabels = { | |
| year: t('年'), | |
| month: t('个月'), | |
| day: t('天'), | |
| hour: t('小时'), | |
| custom: t('自定义'), | |
| }; | |
| if (unit === 'custom') { | |
| const seconds = plan?.custom_seconds || 0; | |
| if (seconds >= 86400) return `${Math.floor(seconds / 86400)} ${t('天')}`; | |
| if (seconds >= 3600) return `${Math.floor(seconds / 3600)} ${t('小时')}`; | |
| return `${seconds} ${t('秒')}`; | |
| } | |
| return `${value} ${unitLabels[unit] || unit}`; | |
| } | |
| export function formatSubscriptionResetPeriod(plan, t) { | |
| const period = plan?.quota_reset_period || 'never'; | |
| if (period === 'never') return t('不重置'); | |
| if (period === 'daily') return t('每天'); | |
| if (period === 'weekly') return t('每周'); | |
| if (period === 'monthly') return t('每月'); | |
| if (period === 'custom') { | |
| const seconds = Number(plan?.quota_reset_custom_seconds || 0); | |
| if (seconds >= 86400) return `${Math.floor(seconds / 86400)} ${t('天')}`; | |
| if (seconds >= 3600) return `${Math.floor(seconds / 3600)} ${t('小时')}`; | |
| if (seconds >= 60) return `${Math.floor(seconds / 60)} ${t('分钟')}`; | |
| return `${seconds} ${t('秒')}`; | |
| } | |
| return t('不重置'); | |
| } | |