mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-27 16:26:16 +08:00
style: format code across frontend and backend files
This commit is contained in:
@@ -876,7 +876,13 @@ mod tests {
|
||||
.await
|
||||
.unwrap_err();
|
||||
// AppError::localized returns AppError::Localized variant
|
||||
assert!(matches!(err, AppError::Localized { key: "error.invalidMultiplier", .. }));
|
||||
assert!(matches!(
|
||||
err,
|
||||
AppError::Localized {
|
||||
key: "error.invalidMultiplier",
|
||||
..
|
||||
}
|
||||
));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -897,7 +903,13 @@ mod tests {
|
||||
.await
|
||||
.unwrap_err();
|
||||
// AppError::localized returns AppError::Localized variant
|
||||
assert!(matches!(err, AppError::Localized { key: "error.invalidPricingMode", .. }));
|
||||
assert!(matches!(
|
||||
err,
|
||||
AppError::Localized {
|
||||
key: "error.invalidPricingMode",
|
||||
..
|
||||
}
|
||||
));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -13,7 +13,9 @@ use serde::Deserialize;
|
||||
use serde_json::Value;
|
||||
|
||||
use crate::app_config::AppType;
|
||||
use crate::config_merge::{extract_json_difference, extract_toml_difference_str, is_common_config_enabled};
|
||||
use crate::config_merge::{
|
||||
extract_json_difference, extract_toml_difference_str, is_common_config_enabled,
|
||||
};
|
||||
use crate::error::AppError;
|
||||
use crate::provider::{Provider, UsageResult};
|
||||
use crate::services::mcp::McpService;
|
||||
@@ -388,7 +390,8 @@ impl ProviderService {
|
||||
if let Ok(live_config) = read_live_settings(app_type.clone()) {
|
||||
if let Some(mut current_provider) = providers.get(¤t_id).cloned() {
|
||||
// Check if common config is enabled for this provider
|
||||
let common_enabled = is_common_config_enabled(current_provider.meta.as_ref(), &app_type);
|
||||
let common_enabled =
|
||||
is_common_config_enabled(current_provider.meta.as_ref(), &app_type);
|
||||
|
||||
let config_to_save = if common_enabled {
|
||||
// Extract custom config from live (remove common config parts)
|
||||
@@ -509,7 +512,8 @@ impl ProviderService {
|
||||
if let Some(config_str) = live_config.get("config").and_then(|v| v.as_str()) {
|
||||
// Extract TOML difference for config field
|
||||
// Returns (custom_toml, has_common_keys, error)
|
||||
let (custom_toml, _, _) = extract_toml_difference_str(config_str, &common_snippet);
|
||||
let (custom_toml, _, _) =
|
||||
extract_toml_difference_str(config_str, &common_snippet);
|
||||
if let Some(obj) = result.as_object_mut() {
|
||||
obj.insert("config".to_string(), Value::String(custom_toml));
|
||||
}
|
||||
|
||||
@@ -1518,18 +1518,11 @@ impl ProxyService {
|
||||
AppType::from_str(app_type).map_err(|_| format!("无效的应用类型: {app_type}"))?;
|
||||
|
||||
// Get common config snippet for merge
|
||||
let common_snippet = self
|
||||
.db
|
||||
.get_config_snippet(app_type)
|
||||
.ok()
|
||||
.flatten();
|
||||
let common_snippet = self.db.get_config_snippet(app_type).ok().flatten();
|
||||
|
||||
// Merge custom config with common config to get final config
|
||||
let merge_result = merge_config_for_live(
|
||||
&app_type_enum,
|
||||
provider,
|
||||
common_snippet.as_deref(),
|
||||
);
|
||||
let merge_result =
|
||||
merge_config_for_live(&app_type_enum, provider, common_snippet.as_deref());
|
||||
|
||||
// Log warning if any
|
||||
if let Some(warning) = &merge_result.warning {
|
||||
|
||||
Reference in New Issue
Block a user