mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-07 18:07:47 +08:00
feat(claude-code): 只读展示重置机会(cedar_ember)并补齐额度文案国际化
This commit is contained in:
@@ -539,6 +539,7 @@ export interface ClaudeCodeUpstreamMetadata {
|
||||
seven_day_sonnet_reset_at?: number
|
||||
seven_day_fable_used_percent?: number
|
||||
seven_day_fable_reset_at?: number
|
||||
reset_credits?: QuotaResetCreditsSnapshot
|
||||
}
|
||||
|
||||
export interface UpstreamMetadata {
|
||||
|
||||
@@ -441,6 +441,33 @@
|
||||
</template>
|
||||
</ProviderQuotaProgressRow>
|
||||
</div>
|
||||
<div
|
||||
v-if="getClaudeCodeResetCreditAvailableCount(key) !== null"
|
||||
class="mt-3 border-t border-border/60 pt-2"
|
||||
>
|
||||
<div class="flex flex-wrap items-center gap-x-1 gap-y-1 text-[10px] leading-4 text-muted-foreground">
|
||||
<span>{{ formatCodexResetCreditCountLabel(getClaudeCodeResetCreditAvailableCount(key)) }}</span>
|
||||
<template v-if="getVisibleClaudeCodeResetCreditItems(key).length > 0">
|
||||
<span aria-hidden="true">|</span>
|
||||
<span>{{ legacyT('临近过期') }}</span>
|
||||
<template
|
||||
v-for="(item, itemIndex) in getVisibleClaudeCodeResetCreditItems(key)"
|
||||
:key="`${item.displayKey}-${item.expiresAt}`"
|
||||
>
|
||||
<span
|
||||
:title="item.title"
|
||||
class="tabular-nums"
|
||||
>
|
||||
{{ item.displayKey }} {{ formatCodexResetCreditExpiresAt(item.expiresAt) }}
|
||||
</span>
|
||||
<span
|
||||
v-if="itemIndex < getVisibleClaudeCodeResetCreditItems(key).length - 1"
|
||||
aria-hidden="true"
|
||||
>·</span>
|
||||
</template>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Gemini CLI 上游模型配额 -->
|
||||
<div
|
||||
@@ -3646,6 +3673,25 @@ function getClaudeCodeQuotaUpdatedAt(key: EndpointAPIKey): number | undefined {
|
||||
return Number.isFinite(updatedAt) && updatedAt > 0 ? updatedAt : undefined
|
||||
}
|
||||
|
||||
function getClaudeCodeResetCreditsDisplay(key: EndpointAPIKey): QuotaResetCreditsSnapshot | null {
|
||||
return getQuotaSnapshotForProvider(key, 'claude_code')?.reset_credits
|
||||
?? key.upstream_metadata?.claude_code?.reset_credits
|
||||
?? null
|
||||
}
|
||||
|
||||
function getClaudeCodeResetCreditAvailableCount(key: EndpointAPIKey): number | null {
|
||||
return getCodexResetCreditAvailableCountFromSnapshot(getClaudeCodeResetCreditsDisplay(key))
|
||||
}
|
||||
|
||||
function getVisibleClaudeCodeResetCreditItems(key: EndpointAPIKey) {
|
||||
return getVisibleCodexResetCreditItemsFromSnapshot(
|
||||
getClaudeCodeResetCreditsDisplay(key),
|
||||
undefined,
|
||||
5,
|
||||
legacyT('Claude 重置机会'),
|
||||
)
|
||||
}
|
||||
|
||||
function hasClaudeCodeQuotaDisplayData(key: EndpointAPIKey): boolean {
|
||||
return getClaudeCodeQuotaItems(key).length > 0
|
||||
}
|
||||
|
||||
@@ -272,6 +272,7 @@ export function getVisibleCodexResetCreditItems(
|
||||
snapshot: QuotaResetCreditsSnapshot | null | undefined,
|
||||
nowUnixSecs = Math.floor(Date.now() / 1000),
|
||||
limit = 5,
|
||||
titleLabel = 'Codex 重置机会',
|
||||
): CodexResetCreditDisplayItem[] {
|
||||
const credits = snapshot?.credits
|
||||
if (!snapshot || !Array.isArray(credits)) return []
|
||||
@@ -295,7 +296,7 @@ export function getVisibleCodexResetCreditItems(
|
||||
return {
|
||||
...item,
|
||||
displayKey,
|
||||
title: `Codex 重置机会 ${displayKey}`,
|
||||
title: `${titleLabel} ${displayKey}`,
|
||||
} satisfies CodexResetCreditDisplayItem
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
export const legacyAdminEnglishMessages: Record<string, string> = {
|
||||
'缺少 OAuth 认证信息,请先授权/刷新 Token': 'Missing OAuth credentials; please authorize or refresh the token first',
|
||||
'Key 状态写入失败': 'Failed to save key status',
|
||||
'找不到有效的 claude:messages 端点': 'No active claude:messages endpoint found',
|
||||
'响应中未包含配额信息': 'The response contains no quota information',
|
||||
'响应中未包含额度窗口': 'The response contains no quota windows',
|
||||
'oauth/usage 请求执行失败': 'oauth/usage request failed',
|
||||
|
||||
@@ -1420,6 +1420,7 @@ export const legacyUiEnglishMessages: Record<string, string> = {
|
||||
'批量导入': 'Bulk import',
|
||||
'继续确认重置': 'Continue checking reset',
|
||||
'临近过期': 'Expiring soon',
|
||||
'Claude 重置机会': 'Claude quota reset',
|
||||
'暂无密钥配置': 'No keys configured',
|
||||
'暂无账号配置': 'No accounts configured',
|
||||
'点击上方"添加密钥"按钮创建第一个密钥': 'Add your first key to get started',
|
||||
|
||||
@@ -3077,6 +3077,8 @@ const legacyDynamicPatterns: Array<[RegExp, (match: RegExpMatchArray) => string]
|
||||
[/^总可用:(.+)$/u, match => `Total available: ${match[1]}`],
|
||||
[/^余额:(.+)$/u, match => `Balance: ${match[1]}`],
|
||||
[/^oauth\/usage 返回状态码 (\d+)$/u, match => `oauth/usage returned status ${match[1]}`],
|
||||
[/^共 (\d+) 次机会$/u, match => `${match[1]} ${match[1] === '1' ? 'chance' : 'chances'} in total`],
|
||||
[/^已处理 (\d+) 个 Key$/u, match => `Processed ${match[1]} ${match[1] === '1' ? 'key' : 'keys'}`],
|
||||
[/^(.+) 秒$/u, match => `${translateLegacyText(match[1], 'en-US')}s`],
|
||||
[/^(.+) 分钟$/u, match => `${translateLegacyText(match[1], 'en-US')} min`],
|
||||
[/^(.+) 小时$/u, match => `${translateLegacyText(match[1], 'en-US')} h`],
|
||||
|
||||
@@ -2274,7 +2274,19 @@ function getPendingCodexResetCreditIdempotencyKey(key: PoolKeyDetail): string |
|
||||
: readPendingCodexResetCreditIdempotencyKey(key.key_id, generation)
|
||||
}
|
||||
|
||||
function getClaudeCodeResetCredits(key: PoolKeyDetail) {
|
||||
if (getQuotaSnapshotProviderType(key) !== 'claude_code') return null
|
||||
return key.status_snapshot?.quota?.reset_credits
|
||||
?? key.upstream_metadata?.claude_code?.reset_credits
|
||||
?? null
|
||||
}
|
||||
|
||||
function getCodexResetCreditCountText(key: PoolKeyDetail): string | null {
|
||||
const claudeCredits = getClaudeCodeResetCredits(key)
|
||||
if (claudeCredits) {
|
||||
const claudeCount = getCodexResetCreditAvailableCount(claudeCredits)
|
||||
return claudeCount === null ? null : formatCodexResetCreditCount(claudeCount)
|
||||
}
|
||||
const count = getCodexResetCreditAvailableCount(getCodexResetCredits(key))
|
||||
return count === null && !getPendingCodexResetCreditIdempotencyKey(key)
|
||||
? null
|
||||
@@ -2282,7 +2294,11 @@ function getCodexResetCreditCountText(key: PoolKeyDetail): string | null {
|
||||
}
|
||||
|
||||
function getCodexResetCreditItemTexts(key: PoolKeyDetail): string[] {
|
||||
return getVisibleCodexResetCreditItems(getCodexResetCredits(key), undefined, 3)
|
||||
return getVisibleCodexResetCreditItems(
|
||||
getClaudeCodeResetCredits(key) ?? getCodexResetCredits(key),
|
||||
undefined,
|
||||
3,
|
||||
)
|
||||
.map(item => `${item.displayKey} ${formatCodexResetCreditExpiresAt(item.expiresAt)}`)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user