diff --git a/src/services/claudeConsoleAccountService.js b/src/services/claudeConsoleAccountService.js index 6581b22c..e7385bdd 100644 --- a/src/services/claudeConsoleAccountService.js +++ b/src/services/claudeConsoleAccountService.js @@ -307,6 +307,14 @@ class ClaudeConsoleAccountService { throw new Error('Account not found') } + // 如果限流时间设置为 0,表示不启用限流机制,直接返回 + if (account.rateLimitDuration === 0) { + logger.info( + `ℹ️ Claude Console account ${account.name} (${accountId}) has rate limiting disabled, skipping rate limit` + ) + return { success: true, skipped: true } + } + const updates = { rateLimitedAt: new Date().toISOString(), rateLimitStatus: 'limited' @@ -351,6 +359,11 @@ class ClaudeConsoleAccountService { return false } + // 如果限流时间设置为 0,表示不启用限流机制 + if (account.rateLimitDuration === 0) { + return false + } + if (account.rateLimitStatus === 'limited' && account.rateLimitedAt) { const rateLimitedAt = new Date(account.rateLimitedAt) const now = new Date() diff --git a/web/admin-spa/src/components/accounts/AccountForm.vue b/web/admin-spa/src/components/accounts/AccountForm.vue index f16c244a..86faf2de 100644 --- a/web/admin-spa/src/components/accounts/AccountForm.vue +++ b/web/admin-spa/src/components/accounts/AccountForm.vue @@ -350,19 +350,34 @@
- - -

- 当账号返回429错误时,暂停调度的时间(分钟) -

+ +
+ +

+ 启用后,当账号返回429错误时将暂停调度一段时间 +

+
+ +
+ + +

账号被限流后暂停调度的时间(分钟)

+
@@ -509,19 +524,34 @@
- - -

- 当账号返回429错误时,暂停调度的时间(分钟) -

+ +
+ +

+ 启用后,当账号返回429错误时将暂停调度一段时间 +

+
+ +
+ + +

账号被限流后暂停调度的时间(分钟)

+
@@ -1080,13 +1110,33 @@
- - + +
+ +

+ 启用后,当账号返回429错误时将暂停调度一段时间 +

+
+ +
+ + +

账号被限流后暂停调度的时间(分钟)

+
@@ -1179,13 +1229,33 @@
- - + +
+ +

+ 启用后,当账号返回429错误时将暂停调度一段时间 +

+
+ +
+ + +

账号被限流后暂停调度的时间(分钟)

+
@@ -1373,6 +1443,8 @@ const form = ref({ return '' })(), userAgent: props.account?.userAgent || '', + enableRateLimit: + props.account?.rateLimitDuration && props.account?.rateLimitDuration > 0 ? true : false, rateLimitDuration: props.account?.rateLimitDuration || 60, // Bedrock 特定字段 accessKeyId: props.account?.accessKeyId || '', @@ -1809,7 +1881,8 @@ const createAccount = async () => { data.priority = form.value.priority || 50 data.supportedModels = convertMappingsToObject() || {} data.userAgent = form.value.userAgent || null - data.rateLimitDuration = form.value.rateLimitDuration || 60 + // 如果不启用限流,传递 0 表示不限流 + data.rateLimitDuration = form.value.enableRateLimit ? form.value.rateLimitDuration || 60 : 0 } else if (form.value.platform === 'bedrock') { // Bedrock 账户特定数据 - 构造 awsCredentials 对象 data.awsCredentials = { @@ -1821,7 +1894,8 @@ const createAccount = async () => { data.defaultModel = form.value.defaultModel || null data.smallFastModel = form.value.smallFastModel || null data.priority = form.value.priority || 50 - data.rateLimitDuration = form.value.rateLimitDuration || 60 + // 如果不启用限流,传递 0 表示不限流 + data.rateLimitDuration = form.value.enableRateLimit ? form.value.rateLimitDuration || 60 : 0 } let result @@ -1964,7 +2038,8 @@ const updateAccount = async () => { data.priority = form.value.priority || 50 data.supportedModels = convertMappingsToObject() || {} data.userAgent = form.value.userAgent || null - data.rateLimitDuration = form.value.rateLimitDuration || 60 + // 如果不启用限流,传递 0 表示不限流 + data.rateLimitDuration = form.value.enableRateLimit ? form.value.rateLimitDuration || 60 : 0 } // Bedrock 特定更新 @@ -1989,7 +2064,8 @@ const updateAccount = async () => { data.defaultModel = form.value.defaultModel || null data.smallFastModel = form.value.smallFastModel || null data.priority = form.value.priority || 50 - data.rateLimitDuration = form.value.rateLimitDuration || 60 + // 如果不启用限流,传递 0 表示不限流 + data.rateLimitDuration = form.value.enableRateLimit ? form.value.rateLimitDuration || 60 : 0 } if (props.account.platform === 'claude') { @@ -2272,6 +2348,8 @@ watch( return '' })(), userAgent: newAccount.userAgent || '', + enableRateLimit: + newAccount.rateLimitDuration && newAccount.rateLimitDuration > 0 ? true : false, rateLimitDuration: newAccount.rateLimitDuration || 60, // Bedrock 特定字段 accessKeyId: '', // 编辑模式不显示现有的访问密钥