feat(common-config): add extract from current provider functionality

- Add backend command to extract common config snippet from current provider
- Automatically extract common config on first run after importing default provider
- Auto-enable common config checkbox in new provider mode when snippet exists
- Refactor Gemini common config to operate on .env instead of config.json
- Add "Extract from Current" button to all three common config modals
- Update i18n translations for new extraction feature
This commit is contained in:
Jason
2026-01-03 23:43:39 +08:00
parent c049c5f2bb
commit 188c94f2e3
17 changed files with 892 additions and 295 deletions
+15
View File
@@ -219,3 +219,18 @@ pub async fn set_common_config_snippet(
.map_err(|e| e.to_string())?;
Ok(())
}
/// 从当前供应商提取通用配置片段
///
/// 读取当前激活供应商的配置,自动排除差异化字段(API Key、模型配置、端点等),
/// 返回可复用的通用配置片段。
#[tauri::command]
pub async fn extract_common_config_snippet(
app_type: String,
state: tauri::State<'_, crate::store::AppState>,
) -> Result<String, String> {
let app = AppType::from_str(&app_type).map_err(|e| e.to_string())?;
crate::services::provider::ProviderService::extract_common_config_snippet(&state, app)
.map_err(|e| e.to_string())
}