feat: show provider expire message with i18n (#237)

This commit is contained in:
PuerNya 2023-09-18 13:45:15 +08:00 committed by GitHub
parent 9ed73a69e3
commit b9e9a955f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 2 deletions

View File

@ -1,3 +1,4 @@
import { useI18n } from '@solid-primitives/i18n'
import byteSize from 'byte-size' import byteSize from 'byte-size'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { toFinite } from 'lodash' import { toFinite } from 'lodash'
@ -12,9 +13,17 @@ const getSubscriptionsInfo = (subscriptionInfo: ISubscriptionInfo) => {
}) })
const percentage = toFinite((((Download + Upload) / Total) * 100).toFixed(2)) const percentage = toFinite((((Download + Upload) / Total) * 100).toFixed(2))
const expirePrefix = () => {
const [t] = useI18n()
return t('expire')
}
const expireStr = () => { const expireStr = () => {
const [t] = useI18n()
if (Expire === 0) { if (Expire === 0) {
return 'Null' return t('noExpire')
} }
return dayjs(Expire * 1000).format('YYYY-MM-DD') return dayjs(Expire * 1000).format('YYYY-MM-DD')
@ -24,6 +33,7 @@ const getSubscriptionsInfo = (subscriptionInfo: ISubscriptionInfo) => {
total, total,
used, used,
percentage, percentage,
expirePrefix,
expireStr, expireStr,
} }
} }
@ -45,7 +55,9 @@ export const SubscriptionInfo = (props: {
{`${info.used}`} / {`${info.total}`} ( {info.percentage}% ) {`${info.used}`} / {`${info.total}`} ( {info.percentage}% )
</div> </div>
<div class="text-sm text-slate-500">Expire: {info.expireStr()} </div> <div class="text-sm text-slate-500">
{info.expirePrefix()}: {info.expireStr()}
</div>
</> </>
) )
} }

View File

@ -94,4 +94,6 @@ export default {
coreConfig: 'Core Config', coreConfig: 'Core Config',
xdConfig: 'XD Config', xdConfig: 'XD Config',
version: 'Version', version: 'Version',
expire: 'Expire',
noExpire: 'Null',
} }

View File

@ -94,4 +94,6 @@ export default {
coreConfig: '核心配置', coreConfig: '核心配置',
xdConfig: 'XD 配置', xdConfig: 'XD 配置',
version: '版本', version: '版本',
expire: '到期时间',
noExpire: '不限时',
} }