style: apply code formatting across backend and frontend (#252)
Apply cargo fmt and prettier formatting to improve code readability. No functional changes. Changes: - Rust: multi-line assertion formatting (gemini_config, env_checker) - Rust: simplify chained method calls (provider) - TypeScript: add trailing commas to function parameters (codexProviderPresets)
This commit is contained in:
@@ -381,14 +381,20 @@ GEMINI_MODEL=gemini-3-pro-preview
|
||||
Some(&"https://example.com".to_string())
|
||||
);
|
||||
assert_eq!(map.get("GEMINI_API_KEY"), Some(&"sk-test123".to_string()));
|
||||
assert_eq!(map.get("GEMINI_MODEL"), Some(&"gemini-3-pro-preview".to_string()));
|
||||
assert_eq!(
|
||||
map.get("GEMINI_MODEL"),
|
||||
Some(&"gemini-3-pro-preview".to_string())
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_serialize_env_file() {
|
||||
let mut map = HashMap::new();
|
||||
map.insert("GEMINI_API_KEY".to_string(), "sk-test".to_string());
|
||||
map.insert("GEMINI_MODEL".to_string(), "gemini-3-pro-preview".to_string());
|
||||
map.insert(
|
||||
"GEMINI_MODEL".to_string(),
|
||||
"gemini-3-pro-preview".to_string(),
|
||||
);
|
||||
|
||||
let content = serialize_env_file(&map);
|
||||
|
||||
@@ -432,7 +438,10 @@ GEMINI_MODEL=gemini-3-pro-preview
|
||||
Some(&"https://example.com".to_string())
|
||||
);
|
||||
assert_eq!(map.get("GEMINI_API_KEY"), Some(&"sk-test123".to_string()));
|
||||
assert_eq!(map.get("GEMINI_MODEL"), Some(&"gemini-3-pro-preview".to_string()));
|
||||
assert_eq!(
|
||||
map.get("GEMINI_MODEL"),
|
||||
Some(&"gemini-3-pro-preview".to_string())
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -159,7 +159,10 @@ mod tests {
|
||||
fn test_get_keywords() {
|
||||
assert_eq!(get_keywords_for_app("claude"), vec!["ANTHROPIC"]);
|
||||
assert_eq!(get_keywords_for_app("codex"), vec!["OPENAI"]);
|
||||
assert_eq!(get_keywords_for_app("gemini"), vec!["GEMINI", "GOOGLE_GEMINI"]);
|
||||
assert_eq!(
|
||||
get_keywords_for_app("gemini"),
|
||||
vec!["GEMINI", "GOOGLE_GEMINI"]
|
||||
);
|
||||
assert_eq!(get_keywords_for_app("unknown"), Vec::<&str>::new());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -863,10 +863,7 @@ impl ProviderService {
|
||||
|
||||
let env_map = read_gemini_env()?;
|
||||
let env_json = env_to_json(&env_map);
|
||||
let env_obj = env_json
|
||||
.get("env")
|
||||
.cloned()
|
||||
.unwrap_or_else(|| json!({}));
|
||||
let env_obj = env_json.get("env").cloned().unwrap_or_else(|| json!({}));
|
||||
|
||||
// 读取 settings.json 文件(MCP 配置等)
|
||||
let settings_path = get_gemini_settings_path();
|
||||
@@ -951,10 +948,7 @@ impl ProviderService {
|
||||
|
||||
let env_map = read_gemini_env()?;
|
||||
let env_json = env_to_json(&env_map);
|
||||
let env_obj = env_json
|
||||
.get("env")
|
||||
.cloned()
|
||||
.unwrap_or_else(|| json!({}));
|
||||
let env_obj = env_json.get("env").cloned().unwrap_or_else(|| json!({}));
|
||||
|
||||
// 读取 settings.json 文件(MCP 配置等)
|
||||
let settings_path = get_gemini_settings_path();
|
||||
|
||||
@@ -37,7 +37,7 @@ export function generateThirdPartyAuth(apiKey: string): Record<string, any> {
|
||||
export function generateThirdPartyConfig(
|
||||
providerName: string,
|
||||
baseUrl: string,
|
||||
modelName = "gpt-5-codex"
|
||||
modelName = "gpt-5-codex",
|
||||
): string {
|
||||
// 清理供应商名称,确保符合TOML键名规范
|
||||
const cleanProviderName =
|
||||
@@ -106,7 +106,7 @@ requires_openai_auth = true`,
|
||||
config: generateThirdPartyConfig(
|
||||
"aihubmix",
|
||||
"https://aihubmix.com/v1",
|
||||
"gpt-5-codex"
|
||||
"gpt-5-codex",
|
||||
),
|
||||
endpointCandidates: [
|
||||
"https://aihubmix.com/v1",
|
||||
@@ -121,7 +121,7 @@ requires_openai_auth = true`,
|
||||
config: generateThirdPartyConfig(
|
||||
"dmxapi",
|
||||
"https://www.dmxapi.cn/v1",
|
||||
"gpt-5-codex"
|
||||
"gpt-5-codex",
|
||||
),
|
||||
endpointCandidates: ["https://www.dmxapi.cn/v1"],
|
||||
},
|
||||
@@ -134,7 +134,7 @@ requires_openai_auth = true`,
|
||||
config: generateThirdPartyConfig(
|
||||
"packycode",
|
||||
"https://www.packyapi.com/v1",
|
||||
"gpt-5-codex"
|
||||
"gpt-5-codex",
|
||||
),
|
||||
endpointCandidates: [
|
||||
"https://www.packyapi.com/v1",
|
||||
|
||||
Reference in New Issue
Block a user