From a2688603fb66fe8d2768749a45907cd528d7f9c6 Mon Sep 17 00:00:00 2001 From: YoVinchen Date: Sat, 22 Nov 2025 23:27:54 +0800 Subject: [PATCH] refactor(backend): update supporting modules for database compatibility - Add DatabaseError variant to AppError enum - Update provider module to support database-backed operations - Modify codex_config to work with new database structure - Ensure error handling covers database operations --- src-tauri/src/codex_config.rs | 2 ++ src-tauri/src/error.rs | 2 ++ src-tauri/src/provider.rs | 5 +++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/codex_config.rs b/src-tauri/src/codex_config.rs index c3a5e19..1d74b43 100644 --- a/src-tauri/src/codex_config.rs +++ b/src-tauri/src/codex_config.rs @@ -29,6 +29,7 @@ pub fn get_codex_config_path() -> PathBuf { } /// 获取 Codex 供应商配置文件路径 +#[allow(dead_code)] pub fn get_codex_provider_paths( provider_id: &str, provider_name: Option<&str>, @@ -44,6 +45,7 @@ pub fn get_codex_provider_paths( } /// 删除 Codex 供应商配置文件 +#[allow(dead_code)] pub fn delete_codex_provider_config( provider_id: &str, provider_name: &str, diff --git a/src-tauri/src/error.rs b/src-tauri/src/error.rs index cd4cf3b..b8f23b0 100644 --- a/src-tauri/src/error.rs +++ b/src-tauri/src/error.rs @@ -50,6 +50,8 @@ pub enum AppError { zh: String, en: String, }, + #[error("数据库错误: {0}")] + Database(String), } impl AppError { diff --git a/src-tauri/src/provider.rs b/src-tauri/src/provider.rs index 2d753b5..75e01f4 100644 --- a/src-tauri/src/provider.rs +++ b/src-tauri/src/provider.rs @@ -1,3 +1,4 @@ +use indexmap::IndexMap; use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collections::HashMap; @@ -64,7 +65,7 @@ impl Provider { /// 供应商管理器 #[derive(Debug, Clone, Serialize, Deserialize, Default)] pub struct ProviderManager { - pub providers: HashMap, + pub providers: IndexMap, pub current: String, } @@ -154,7 +155,7 @@ pub struct ProviderMeta { impl ProviderManager { /// 获取所有供应商 - pub fn get_all_providers(&self) -> &HashMap { + pub fn get_all_providers(&self) -> &IndexMap { &self.providers } }