style: format code across frontend and backend files

This commit is contained in:
YoVinchen
2026-01-29 00:59:05 +08:00
parent 3f68f78331
commit 7974650ad8
6 changed files with 398 additions and 387 deletions
+14 -2
View File
@@ -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(())
}
+7 -3
View File
@@ -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(&current_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));
}
+3 -10
View File
@@ -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 {