chore(tauri): remove dead code warnings and drop unused uuid dep
- Delete unused Provider::new, ProviderManager::get_current_provider - Delete unused AppState::reload - Remove uuid crate and related imports - Keep functionality unchanged; frontend uses ID string for current provider
This commit is contained in:
@@ -2,7 +2,6 @@ use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
use std::collections::HashMap;
|
||||
use std::path::Path;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::config::{
|
||||
copy_file, delete_file, get_provider_config_path, read_json_file, write_json_file,
|
||||
@@ -22,16 +21,6 @@ pub struct Provider {
|
||||
}
|
||||
|
||||
impl Provider {
|
||||
/// 创建新的供应商
|
||||
pub fn new(name: String, settings_config: Value, website_url: Option<String>) -> Self {
|
||||
Self {
|
||||
id: Uuid::new_v4().to_string(),
|
||||
name,
|
||||
settings_config,
|
||||
website_url,
|
||||
}
|
||||
}
|
||||
|
||||
/// 从现有ID创建供应商
|
||||
pub fn with_id(id: String, name: String, settings_config: Value, website_url: Option<String>) -> Self {
|
||||
Self {
|
||||
@@ -170,15 +159,6 @@ impl ProviderManager {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// 获取当前供应商
|
||||
pub fn get_current_provider(&self) -> Option<&Provider> {
|
||||
if self.current.is_empty() {
|
||||
None
|
||||
} else {
|
||||
self.providers.get(&self.current)
|
||||
}
|
||||
}
|
||||
|
||||
/// 获取所有供应商
|
||||
pub fn get_all_providers(&self) -> &HashMap<String, Provider> {
|
||||
&self.providers
|
||||
|
||||
@@ -31,15 +31,5 @@ impl AppState {
|
||||
manager.save_to_file(&config_path)
|
||||
}
|
||||
|
||||
/// 重新加载配置
|
||||
pub fn reload(&self) -> Result<(), String> {
|
||||
let config_path = get_app_config_path();
|
||||
let new_manager = ProviderManager::load_from_file(&config_path)?;
|
||||
|
||||
let mut manager = self.provider_manager.lock()
|
||||
.map_err(|e| format!("获取锁失败: {}", e))?;
|
||||
|
||||
*manager = new_manager;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
// 保留按需扩展:若未来需要热加载,可在此实现
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user