mirror of
https://gitee.com/wanwujie/sub2api
synced 2026-04-16 21:04:45 +08:00
fix: 修复 OpenAI WS 用量窗口刷新与限额纠偏
This commit is contained in:
28
frontend/src/utils/accountUsageRefresh.ts
Normal file
28
frontend/src/utils/accountUsageRefresh.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import type { Account } from '@/types'
|
||||
|
||||
const normalizeUsageRefreshValue = (value: unknown): string => {
|
||||
if (value == null) return ''
|
||||
return String(value)
|
||||
}
|
||||
|
||||
export const buildOpenAIUsageRefreshKey = (account: Pick<Account, 'id' | 'platform' | 'type' | 'updated_at' | 'rate_limit_reset_at' | 'extra'>): string => {
|
||||
if (account.platform !== 'openai' || account.type !== 'oauth') {
|
||||
return ''
|
||||
}
|
||||
|
||||
const extra = account.extra ?? {}
|
||||
return [
|
||||
account.id,
|
||||
account.updated_at,
|
||||
account.rate_limit_reset_at,
|
||||
extra.codex_usage_updated_at,
|
||||
extra.codex_5h_used_percent,
|
||||
extra.codex_5h_reset_at,
|
||||
extra.codex_5h_reset_after_seconds,
|
||||
extra.codex_5h_window_minutes,
|
||||
extra.codex_7d_used_percent,
|
||||
extra.codex_7d_reset_at,
|
||||
extra.codex_7d_reset_after_seconds,
|
||||
extra.codex_7d_window_minutes
|
||||
].map(normalizeUsageRefreshValue).join('|')
|
||||
}
|
||||
Reference in New Issue
Block a user