Merge pull request #317 from f3n9/um-5

修复账户管理页中Azure/OpenAI类型账户调度状态不准确的问题
This commit is contained in:
Wesley Liddick
2025-09-02 11:29:27 +08:00
committed by GitHub
3 changed files with 15 additions and 5 deletions

View File

@@ -296,7 +296,11 @@ async function getAllAccounts() {
} }
} }
accounts.push(accountData) accounts.push({
...accountData,
isActive: accountData.isActive === 'true',
schedulable: accountData.schedulable !== 'false'
})
} }
} }

View File

@@ -502,6 +502,8 @@ async function getAllAccounts() {
// 不解密敏感字段,只返回基本信息 // 不解密敏感字段,只返回基本信息
accounts.push({ accounts.push({
...accountData, ...accountData,
isActive: accountData.isActive === 'true',
schedulable: accountData.schedulable !== 'false',
openaiOauth: accountData.openaiOauth ? '[ENCRYPTED]' : '', openaiOauth: accountData.openaiOauth ? '[ENCRYPTED]' : '',
accessToken: accountData.accessToken ? '[ENCRYPTED]' : '', accessToken: accountData.accessToken ? '[ENCRYPTED]' : '',
refreshToken: accountData.refreshToken ? '[ENCRYPTED]' : '', refreshToken: accountData.refreshToken ? '[ENCRYPTED]' : '',

View File

@@ -34,7 +34,11 @@ class UnifiedOpenAIScheduler {
// 普通专属账户 // 普通专属账户
const boundAccount = await openaiAccountService.getAccount(apiKeyData.openaiAccountId) const boundAccount = await openaiAccountService.getAccount(apiKeyData.openaiAccountId)
if (boundAccount && boundAccount.isActive === 'true' && boundAccount.status !== 'error') { if (
boundAccount &&
(boundAccount.isActive === true || boundAccount.isActive === 'true') &&
boundAccount.status !== 'error'
) {
// 检查是否被限流 // 检查是否被限流
const isRateLimited = await this.isAccountRateLimited(boundAccount.id) const isRateLimited = await this.isAccountRateLimited(boundAccount.id)
if (isRateLimited) { if (isRateLimited) {
@@ -165,7 +169,7 @@ class UnifiedOpenAIScheduler {
const openaiAccounts = await openaiAccountService.getAllAccounts() const openaiAccounts = await openaiAccountService.getAllAccounts()
for (const account of openaiAccounts) { for (const account of openaiAccounts) {
if ( if (
account.isActive === 'true' && account.isActive &&
account.status !== 'error' && account.status !== 'error' &&
(account.accountType === 'shared' || !account.accountType) && // 兼容旧数据 (account.accountType === 'shared' || !account.accountType) && // 兼容旧数据
this._isSchedulable(account.schedulable) this._isSchedulable(account.schedulable)
@@ -233,7 +237,7 @@ class UnifiedOpenAIScheduler {
try { try {
if (accountType === 'openai') { if (accountType === 'openai') {
const account = await openaiAccountService.getAccount(accountId) const account = await openaiAccountService.getAccount(accountId)
if (!account || account.isActive !== 'true' || account.status === 'error') { if (!account || !account.isActive || account.status === 'error') {
return false return false
} }
// 检查是否可调度 // 检查是否可调度
@@ -395,7 +399,7 @@ class UnifiedOpenAIScheduler {
const account = await openaiAccountService.getAccount(memberId) const account = await openaiAccountService.getAccount(memberId)
if ( if (
account && account &&
account.isActive === 'true' && account.isActive &&
account.status !== 'error' && account.status !== 'error' &&
this._isSchedulable(account.schedulable) this._isSchedulable(account.schedulable)
) { ) {