Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
313afe14
Unverified
Commit
313afe14
authored
Mar 08, 2026
by
Wesley Liddick
Committed by
GitHub
Mar 08, 2026
Browse files
Merge pull request #842 from pkssssss/fix/openai-ws-usage-refresh
fix: 修复 OpenAI WS 用量窗口刷新与限额状态不同步
parents
01180b31
9301dae6
Changes
23
Show whitespace changes
Inline
Side-by-side
frontend/src/utils/__tests__/accountUsageRefresh.spec.ts
0 → 100644
View file @
313afe14
import
{
describe
,
expect
,
it
}
from
'
vitest
'
import
{
buildOpenAIUsageRefreshKey
}
from
'
../accountUsageRefresh
'
describe
(
'
buildOpenAIUsageRefreshKey
'
,
()
=>
{
it
(
'
会在 codex 快照变化时生成不同 key
'
,
()
=>
{
const
base
=
{
id
:
1
,
platform
:
'
openai
'
,
type
:
'
oauth
'
,
updated_at
:
'
2026-03-07T10:00:00Z
'
,
extra
:
{
codex_usage_updated_at
:
'
2026-03-07T10:00:00Z
'
,
codex_5h_used_percent
:
0
,
codex_7d_used_percent
:
0
}
}
as
any
const
next
=
{
...
base
,
extra
:
{
...
base
.
extra
,
codex_usage_updated_at
:
'
2026-03-07T10:01:00Z
'
,
codex_5h_used_percent
:
100
}
}
expect
(
buildOpenAIUsageRefreshKey
(
base
)).
not
.
toBe
(
buildOpenAIUsageRefreshKey
(
next
))
})
it
(
'
非 OpenAI OAuth 账号返回空 key
'
,
()
=>
{
expect
(
buildOpenAIUsageRefreshKey
({
id
:
2
,
platform
:
'
anthropic
'
,
type
:
'
oauth
'
,
updated_at
:
'
2026-03-07T10:00:00Z
'
,
extra
:
{}
}
as
any
)).
toBe
(
''
)
})
})
frontend/src/utils/accountUsageRefresh.ts
0 → 100644
View file @
313afe14
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
(
'
|
'
)
}
frontend/src/views/admin/AccountsView.vue
View file @
313afe14
...
@@ -312,6 +312,7 @@ import AccountCapacityCell from '@/components/account/AccountCapacityCell.vue'
...
@@ -312,6 +312,7 @@ import AccountCapacityCell from '@/components/account/AccountCapacityCell.vue'
import
PlatformTypeBadge
from
'
@/components/common/PlatformTypeBadge.vue
'
import
PlatformTypeBadge
from
'
@/components/common/PlatformTypeBadge.vue
'
import
Icon
from
'
@/components/icons/Icon.vue
'
import
Icon
from
'
@/components/icons/Icon.vue
'
import
ErrorPassthroughRulesModal
from
'
@/components/admin/ErrorPassthroughRulesModal.vue
'
import
ErrorPassthroughRulesModal
from
'
@/components/admin/ErrorPassthroughRulesModal.vue
'
import
{
buildOpenAIUsageRefreshKey
}
from
'
@/utils/accountUsageRefresh
'
import
{
formatDateTime
,
formatRelativeTime
}
from
'
@/utils/format
'
import
{
formatDateTime
,
formatRelativeTime
}
from
'
@/utils/format
'
import
type
{
Account
,
AccountPlatform
,
AccountType
,
Proxy
,
AdminGroup
,
WindowStats
,
ClaudeModel
}
from
'
@/types
'
import
type
{
Account
,
AccountPlatform
,
AccountType
,
Proxy
,
AdminGroup
,
WindowStats
,
ClaudeModel
}
from
'
@/types
'
...
@@ -660,7 +661,8 @@ const shouldReplaceAutoRefreshRow = (current: Account, next: Account) => {
...
@@ -660,7 +661,8 @@ const shouldReplaceAutoRefreshRow = (current: Account, next: Account) => {
current
.
status
!==
next
.
status
||
current
.
status
!==
next
.
status
||
current
.
rate_limit_reset_at
!==
next
.
rate_limit_reset_at
||
current
.
rate_limit_reset_at
!==
next
.
rate_limit_reset_at
||
current
.
overload_until
!==
next
.
overload_until
||
current
.
overload_until
!==
next
.
overload_until
||
current
.
temp_unschedulable_until
!==
next
.
temp_unschedulable_until
current
.
temp_unschedulable_until
!==
next
.
temp_unschedulable_until
||
buildOpenAIUsageRefreshKey
(
current
)
!==
buildOpenAIUsageRefreshKey
(
next
)
)
)
}
}
...
...
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment