fix: simplify account self-check config

This commit is contained in:
fawney19
2026-05-15 02:14:46 +08:00
parent 54a8312e46
commit 8e0f8003a9
14 changed files with 75 additions and 658 deletions

View File

@@ -87,6 +87,8 @@ mod tests {
assert!(service.supports_quota_refresh("codex"));
assert!(service.supports_quota_refresh("antigravity"));
assert!(!service.supports_quota_refresh("gemini_cli"));
assert!(service.supports_account_self_check("codex"));
assert!(!service.supports_account_self_check("gemini_cli"));
assert_eq!(
service.quota_refresh_unsupported_message("claude_code"),
"Claude Code 暂不支持自动刷新额度:上游没有稳定可用的账号额度查询接口"

View File

@@ -53,6 +53,21 @@ pub trait ProviderPoolAdapter: Send + Sync {
"找不到有效端点".to_string()
}
fn supports_account_self_check(&self) -> bool {
self.supports_quota_refresh()
}
fn account_self_check_endpoint(
&self,
endpoints: &[StoredProviderCatalogEndpoint],
include_inactive: bool,
) -> Option<StoredProviderCatalogEndpoint> {
if !self.supports_account_self_check() {
return None;
}
self.quota_refresh_endpoint(endpoints, include_inactive)
}
fn normalize_plan_tier(&self, value: &str) -> Option<String> {
normalize_provider_plan_tier(value, self.provider_type())
}

View File

@@ -104,6 +104,20 @@ impl ProviderPoolService {
.quota_refresh_missing_endpoint_message()
}
pub fn supports_account_self_check(&self, provider_type: &str) -> bool {
self.adapter(provider_type).supports_account_self_check()
}
pub fn account_self_check_endpoint_for_provider(
&self,
provider_type: &str,
endpoints: &[StoredProviderCatalogEndpoint],
include_inactive: bool,
) -> Option<StoredProviderCatalogEndpoint> {
self.adapter(provider_type)
.account_self_check_endpoint(endpoints, include_inactive)
}
pub fn normalize_scheduling_presets(
&self,
provider_type: &str,