feat: show current-cycle token totals
This commit is contained in:
+27
-3
@@ -687,6 +687,11 @@ function AccountQuickSummary({
|
||||
<span>
|
||||
{remaining == null ? "限额暂无" : `最低 ${Math.round(remaining)}% 剩余`}
|
||||
</span>
|
||||
<span>
|
||||
{dashboard.currentCycle == null
|
||||
? "本周期 Token 暂无"
|
||||
: `本周期 ${num(dashboard.currentCycle.totalTokens)} Tokens`}
|
||||
</span>
|
||||
<span>{reset ? `最近重置 ${relative(reset)}` : "暂无重置时间"}</span>
|
||||
</span>
|
||||
);
|
||||
@@ -776,11 +781,22 @@ function AccountDashboardDetails({
|
||||
该连接暂无限额数据,请确认登录后刷新。
|
||||
</div>
|
||||
)}
|
||||
{dashboard.currentCycle && (
|
||||
<div className="cycle-note">
|
||||
<Clock />
|
||||
<span>
|
||||
本周期:{cycleTimestamp(dashboard.currentCycle.startedAt)} 至{" "}
|
||||
{cycleTimestamp(dashboard.currentCycle.resetsAt)}(
|
||||
{cycleDuration(dashboard.currentCycle.windowDurationMinutes)}
|
||||
,按每日数据汇总)
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
<div className="stats">
|
||||
<Stat
|
||||
icon={<Coins />}
|
||||
label="累计 Tokens"
|
||||
v={num(dashboard.summary.lifetimeTokens)}
|
||||
label="本周期 Tokens"
|
||||
v={num(dashboard.currentCycle?.totalTokens)}
|
||||
/>
|
||||
<Stat
|
||||
icon={<TrendingUp />}
|
||||
@@ -1664,7 +1680,7 @@ function Header({
|
||||
const num = (v?: number | null) =>
|
||||
v == null
|
||||
? "暂无"
|
||||
: new Intl.NumberFormat("zh-CN", {
|
||||
: new Intl.NumberFormat("en", {
|
||||
notation: "compact",
|
||||
maximumFractionDigits: 1,
|
||||
}).format(v);
|
||||
@@ -1676,6 +1692,14 @@ const duration = (v?: number | null) =>
|
||||
: v < 3600
|
||||
? `${Math.floor(v / 60)} 分 ${v % 60} 秒`
|
||||
: `${(v / 3600).toFixed(1)} 小时`;
|
||||
const cycleTimestamp = (value: number) =>
|
||||
new Date(value * 1000).toLocaleString();
|
||||
const cycleDuration = (minutes: number) =>
|
||||
minutes % (24 * 60) === 0
|
||||
? `${minutes / (24 * 60)} 天窗口`
|
||||
: minutes % 60 === 0
|
||||
? `${minutes / 60} 小时窗口`
|
||||
: `${minutes} 分钟窗口`;
|
||||
const remainingPercent = (limit: Limit) =>
|
||||
100 - Math.min(100, Math.max(0, limit.usedPercent));
|
||||
const limitLabel = (limit: Limit) => {
|
||||
|
||||
Reference in New Issue
Block a user