mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-22 16:43:35 +00:00
Merge pull request #234 from tanaer/bugfix
Fixes: Gemini账户调度状态在页面刷新后与实际设置不符
This commit is contained in:
@@ -2308,16 +2308,21 @@ router.put(
|
||||
return res.status(404).json({ error: 'Account not found' })
|
||||
}
|
||||
|
||||
// 将字符串 'true'/'false' 转换为布尔值,然后取反
|
||||
const currentSchedulable = account.schedulable === 'true'
|
||||
const newSchedulable = !currentSchedulable
|
||||
// 现在 account.schedulable 已经是布尔值了,直接取反即可
|
||||
const newSchedulable = !account.schedulable
|
||||
|
||||
await geminiAccountService.updateAccount(accountId, { schedulable: String(newSchedulable) })
|
||||
|
||||
// 验证更新是否成功,重新获取账户信息
|
||||
const updatedAccount = await geminiAccountService.getAccount(accountId)
|
||||
const actualSchedulable = updatedAccount ? updatedAccount.schedulable : newSchedulable
|
||||
|
||||
logger.success(
|
||||
`🔄 Admin toggled Gemini account schedulable status: ${accountId} -> ${newSchedulable ? 'schedulable' : 'not schedulable'}`
|
||||
`🔄 Admin toggled Gemini account schedulable status: ${accountId} -> ${actualSchedulable ? 'schedulable' : 'not schedulable'}`
|
||||
)
|
||||
return res.json({ success: true, schedulable: newSchedulable })
|
||||
|
||||
// 返回实际的数据库值,确保前端状态与后端一致
|
||||
return res.json({ success: true, schedulable: actualSchedulable })
|
||||
} catch (error) {
|
||||
logger.error('❌ Failed to toggle Gemini account schedulable status:', error)
|
||||
return res
|
||||
|
||||
@@ -363,6 +363,9 @@ async function getAccount(accountId) {
|
||||
}
|
||||
}
|
||||
|
||||
// 转换 schedulable 字符串为布尔值(与 claudeConsoleAccountService 保持一致)
|
||||
accountData.schedulable = accountData.schedulable !== 'false' // 默认为true,只有明确设置为'false'才为false
|
||||
|
||||
return accountData
|
||||
}
|
||||
|
||||
@@ -386,6 +389,11 @@ async function updateAccount(accountId, updates) {
|
||||
updates.proxy = updates.proxy ? JSON.stringify(updates.proxy) : ''
|
||||
}
|
||||
|
||||
// 处理 schedulable 字段,确保正确转换为字符串存储
|
||||
if (updates.schedulable !== undefined) {
|
||||
updates.schedulable = updates.schedulable.toString()
|
||||
}
|
||||
|
||||
// 加密敏感字段
|
||||
if (updates.geminiOauth) {
|
||||
updates.geminiOauth = encrypt(
|
||||
@@ -517,6 +525,9 @@ async function getAllAccounts() {
|
||||
}
|
||||
}
|
||||
|
||||
// 转换 schedulable 字符串为布尔值(与 getAccount 保持一致)
|
||||
accountData.schedulable = accountData.schedulable !== 'false' // 默认为true,只有明确设置为'false'才为false
|
||||
|
||||
// 不解密敏感字段,只返回基本信息
|
||||
accounts.push({
|
||||
...accountData,
|
||||
|
||||
Reference in New Issue
Block a user