feat: show available reset credits

This commit is contained in:
2026-08-22 09:59:10 +08:00
parent 45ceeee936
commit 6a711c1fff
12 changed files with 201 additions and 21 deletions
+18
View File
@@ -24,6 +24,7 @@ import {
MoreHorizontal,
Settings,
Sun,
Ticket,
Trash2,
TrendingUp,
Zap,
@@ -714,6 +715,21 @@ function AccountDashboardDetails({
value={dashboard.stale ? "数据可能已过期" : "数据已更新"}
/>
</div>
{!publicView &&
dashboard.resetCredits &&
dashboard.resetCredits.availableCount > 0 && (
<div className="reset-credits" data-testid="reset-credits">
<Ticket />
<div className="reset-credits-main">
<small>重置卡</small>
<b>可用 {dashboard.resetCredits.availableCount} 张</b>
</div>
<div className="reset-credits-expiry">
<small>到期时间</small>
<b>{formatResetCreditExpiry(dashboard.resetCredits.expiresAt)}</b>
</div>
</div>
)}
<div className="limits">
{dashboard.limits.map((limit, index) => (
<LimitCard
@@ -1646,6 +1662,8 @@ const num = (v?: number | null) =>
}).format(v);
const cycleTimestamp = (value: number) =>
new Date(value * 1000).toLocaleString();
const formatResetCreditExpiry = (values: number[]) =>
values.length ? values.map(cycleTimestamp).join("、") : "服务端未提供";
const cycleDuration = (minutes: number) =>
minutes % (24 * 60) === 0
? `${minutes / (24 * 60)} 天窗口`