[PR #229] [MERGED] feat(config): 添加坏凭证切换最大重试次数配置项,支持自定义配置,默认5。 #310

Closed
opened 2026-02-27 07:18:54 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/justlovemaki/AIClient-2-API/pull/229
Author: @leonaii
Created: 1/13/2026
Status: Merged
Merged: 1/13/2026
Merged by: @justlovemaki

Base: mainHead: main


📝 Commits (1)

  • 4772a6e feat(config): 添加凭证切换最大重试次数配置项

📊 Changes

5 files changed (+24 additions, -1 deletions)

View changed files

📝 src/core/config-manager.js (+1 -0)
📝 src/ui-modules/config-api.js (+2 -0)
📝 src/utils/common.js (+7 -1)
📝 static/app/config-manager.js (+6 -0)
📝 static/components/section-config.html (+8 -0)

📄 Description

📋 概述

新增 CREDENTIAL_SWITCH_MAX_RETRIES 配置项,允许用户自定义凭证切换的最大重试次数,提升系统在多凭证场景下的容错能力。

🎯 动机与背景

当使用 Provider Pool(号池)功能时,系统会在遇到认证错误(401/403)后自动切换到其他健康凭证进行重试。此前重试次数硬编码为 2 次,对于拥有大量凭证的用户来说可能不够灵活。本次更新将该值改为可配置,默认值提升至 5 次。

变更内容

文件 变更说明
src/core/config-manager.js 添加 CREDENTIAL_SWITCH_MAX_RETRIES 配置初始化,默认值为 5
src/ui-modules/config-api.js 支持配置项的读取和更新
src/utils/common.js 使用配置值控制凭证切换重试次数
static/app/config-manager.js 前端配置加载和保存逻辑
static/components/section-config.html 添加配置输入控件

🔧 技术细节

配置初始化:

CREDENTIAL_SWITCH_MAX_RETRIES: 5, // 坏凭证切换最大重试次数(用于认证错误后切换凭证)

使用方式:

// 凭证切换重试次数(默认 5),可在配置中自定义更大的值
// 注意:这与底层的 429/5xx 重试(REQUEST_MAX_RETRIES)是不同层次的重试机制
// - 底层重试:同一凭证遇到 429/5xx 时的重试
// - 凭证切换重试:凭证被标记不健康后切换到其他凭证
// 当没有不同的健康凭证可用时,重试会自动停止
const credentialSwitchMaxRetries = CONFIG.CREDENTIAL_SWITCH_MAX_RETRIES || 5;

📝 重试机制说明

本系统存在两层重试机制:

重试类型 配置项 触发条件 说明
底层重试 REQUEST_MAX_RETRIES 429/5xx 错误 同一凭证内的重试
凭证切换重试 CREDENTIAL_SWITCH_MAX_RETRIES 401/403 错误 切换到其他健康凭证

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/justlovemaki/AIClient-2-API/pull/229 **Author:** [@leonaii](https://github.com/leonaii) **Created:** 1/13/2026 **Status:** ✅ Merged **Merged:** 1/13/2026 **Merged by:** [@justlovemaki](https://github.com/justlovemaki) **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (1) - [`4772a6e`](https://github.com/justlovemaki/AIClient-2-API/commit/4772a6ea00e3a554ed6662e8ca8eb01b4b690eb4) feat(config): 添加凭证切换最大重试次数配置项 ### 📊 Changes **5 files changed** (+24 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/core/config-manager.js` (+1 -0) 📝 `src/ui-modules/config-api.js` (+2 -0) 📝 `src/utils/common.js` (+7 -1) 📝 `static/app/config-manager.js` (+6 -0) 📝 `static/components/section-config.html` (+8 -0) </details> ### 📄 Description ### 📋 概述 新增 `CREDENTIAL_SWITCH_MAX_RETRIES` 配置项,允许用户自定义凭证切换的最大重试次数,提升系统在多凭证场景下的容错能力。 ### 🎯 动机与背景 当使用 Provider Pool(号池)功能时,系统会在遇到认证错误(401/403)后自动切换到其他健康凭证进行重试。此前重试次数硬编码为 2 次,对于拥有大量凭证的用户来说可能不够灵活。本次更新将该值改为可配置,默认值提升至 5 次。 ### ✨ 变更内容 | 文件 | 变更说明 | |------|----------| | `src/core/config-manager.js` | 添加 `CREDENTIAL_SWITCH_MAX_RETRIES` 配置初始化,默认值为 5 | | `src/ui-modules/config-api.js` | 支持配置项的读取和更新 | | `src/utils/common.js` | 使用配置值控制凭证切换重试次数 | | `static/app/config-manager.js` | 前端配置加载和保存逻辑 | | `static/components/section-config.html` | 添加配置输入控件 | ### 🔧 技术细节 **配置初始化:** ```javascript CREDENTIAL_SWITCH_MAX_RETRIES: 5, // 坏凭证切换最大重试次数(用于认证错误后切换凭证) ``` **使用方式:** ```javascript // 凭证切换重试次数(默认 5),可在配置中自定义更大的值 // 注意:这与底层的 429/5xx 重试(REQUEST_MAX_RETRIES)是不同层次的重试机制 // - 底层重试:同一凭证遇到 429/5xx 时的重试 // - 凭证切换重试:凭证被标记不健康后切换到其他凭证 // 当没有不同的健康凭证可用时,重试会自动停止 const credentialSwitchMaxRetries = CONFIG.CREDENTIAL_SWITCH_MAX_RETRIES || 5; ``` ### 📝 重试机制说明 本系统存在两层重试机制: | 重试类型 | 配置项 | 触发条件 | 说明 | |----------|--------|----------|------| | 底层重试 | `REQUEST_MAX_RETRIES` | 429/5xx 错误 | 同一凭证内的重试 | | 凭证切换重试 | `CREDENTIAL_SWITCH_MAX_RETRIES` | 401/403 错误 | 切换到其他健康凭证 | --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 07:18:54 +03:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/AIClient-2-API-justlovemaki#310
No description provided.