feat(frontend): show user credential expiry

This commit is contained in:
2026-05-06 22:13:54 +08:00
parent ce55cfc6b3
commit 3fceb1516c
4 changed files with 63 additions and 0 deletions
@@ -4,6 +4,7 @@ import type { TokenStatus } from '@/api'
import {
canRefreshAuthorization,
formatAuthorizationExpiryTooltip,
formatUserAuthorizationSummary,
formatRemainingDays,
} from './dashboard-license.ts'
@@ -65,3 +66,22 @@ test('formats remaining days label consistently', () => {
assert.equal(formatRemainingDays(0), '0 天')
assert.equal(formatRemainingDays(12), '12 天')
})
test('formats user authorization summary from jwt expiration', () => {
assert.deepEqual(formatUserAuthorizationSummary('0'), {
label: '未绑定凭证',
tone: 'neutral',
})
assert.deepEqual(formatUserAuthorizationSummary('1000', 2000), {
label: '凭证过期',
tone: 'danger',
})
assert.deepEqual(formatUserAuthorizationSummary(String(2000 + 2 * 24 * 60 * 60), 2000), {
label: '2 天后过期',
tone: 'warning',
})
assert.deepEqual(formatUserAuthorizationSummary(String(2000 + 9 * 24 * 60 * 60), 2000), {
label: '9 天后过期',
tone: 'success',
})
})