mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 17:30:23 +08:00
新增 Codex Spark 额度展示
解析 GPT-5.3-Codex-Spark 额度窗口,并在号池页面和提供商账号抽屉中展示 Spark 周额度与 5H 额度。Spark 额度仅用于展示,不影响普通 Codex 周额度和 5H 额度的调度与筛选逻辑。
This commit is contained in:
42
frontend/src/utils/__tests__/providerKeyQuota.spec.ts
Normal file
42
frontend/src/utils/__tests__/providerKeyQuota.spec.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { getQuotaDisplayText } from '../providerKeyQuota'
|
||||
|
||||
describe('providerKeyQuota', () => {
|
||||
it('includes Codex Spark quota windows in display text', () => {
|
||||
expect(getQuotaDisplayText({
|
||||
status_snapshot: {
|
||||
oauth: {
|
||||
code: 'valid',
|
||||
},
|
||||
account: {
|
||||
code: 'ok',
|
||||
blocked: false,
|
||||
},
|
||||
quota: {
|
||||
provider_type: 'codex',
|
||||
code: 'ok',
|
||||
exhausted: false,
|
||||
windows: [
|
||||
{
|
||||
code: 'weekly',
|
||||
remaining_ratio: 0.9,
|
||||
},
|
||||
{
|
||||
code: '5h',
|
||||
remaining_ratio: 0.8,
|
||||
},
|
||||
{
|
||||
code: 'spark_5h',
|
||||
remaining_ratio: 0.6,
|
||||
},
|
||||
{
|
||||
code: 'spark_weekly',
|
||||
remaining_ratio: 0.95,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
}, 'codex')).toBe('周剩余 90.0% | 5H剩余 80.0% | Spark5H剩余 60.0% | Spark周剩余 95.0%')
|
||||
})
|
||||
})
|
||||
@@ -96,7 +96,12 @@ function formatQuotaValue(value: number | null | undefined): string {
|
||||
|
||||
function getCodexQuotaText(quota: QuotaStatusSnapshot): string | null {
|
||||
const parts: string[] = []
|
||||
for (const [label, code] of [['周', 'weekly'], ['5H', '5h']] as const) {
|
||||
for (const [label, code] of [
|
||||
['周', 'weekly'],
|
||||
['5H', '5h'],
|
||||
['Spark5H', 'spark_5h'],
|
||||
['Spark周', 'spark_weekly'],
|
||||
] as const) {
|
||||
const remainingPercent = getQuotaWindowRemainingPercent(getQuotaWindow(quota, code))
|
||||
if (remainingPercent == null) continue
|
||||
parts.push(`${label}剩余 ${formatPercent(remainingPercent)}`)
|
||||
|
||||
Reference in New Issue
Block a user