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:
Jason
2025-08-25 21:41:35 +08:00
parent dac8ebe03b
commit 78bc0a1a31
5 changed files with 3 additions and 66 deletions

30
src-tauri/Cargo.lock generated
View File

@@ -103,8 +103,6 @@ dependencies = [
"tauri-plugin-log", "tauri-plugin-log",
"tauri-plugin-opener", "tauri-plugin-opener",
"tauri-plugin-shell", "tauri-plugin-shell",
"tauri-plugin-store",
"uuid",
] ]
[[package]] [[package]]
@@ -4180,22 +4178,6 @@ dependencies = [
"tokio", "tokio",
] ]
[[package]]
name = "tauri-plugin-store"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d85dd80d60a76ee2c2fdce09e9ef30877b239c2a6bb76e6d7d03708aa5f13a19"
dependencies = [
"dunce",
"serde",
"serde_json",
"tauri",
"tauri-plugin",
"thiserror 2.0.16",
"tokio",
"tracing",
]
[[package]] [[package]]
name = "tauri-runtime" name = "tauri-runtime"
version = "2.8.0" version = "2.8.0"
@@ -4432,21 +4414,9 @@ dependencies = [
"pin-project-lite", "pin-project-lite",
"slab", "slab",
"socket2", "socket2",
"tokio-macros",
"windows-sys 0.59.0", "windows-sys 0.59.0",
] ]
[[package]]
name = "tokio-macros"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.106",
]
[[package]] [[package]]
name = "tokio-util" name = "tokio-util"
version = "0.7.16" version = "0.7.16"

View File

@@ -23,8 +23,6 @@ serde = { version = "1.0", features = ["derive"] }
log = "0.4" log = "0.4"
tauri = { version = "2.8.2", features = [] } tauri = { version = "2.8.2", features = [] }
tauri-plugin-log = "2" tauri-plugin-log = "2"
tauri-plugin-store = "2"
tauri-plugin-shell = "2" tauri-plugin-shell = "2"
tauri-plugin-opener = "2" tauri-plugin-opener = "2"
dirs = "5.0" dirs = "5.0"
uuid = { version = "1.11", features = ["v4", "serde"] }

View File

@@ -8,7 +8,6 @@
"permissions": [ "permissions": [
"core:default", "core:default",
"shell:allow-open", "shell:allow-open",
"shell:allow-execute",
"opener:default" "opener:default"
] ]
} }

View File

@@ -2,7 +2,6 @@ use serde::{Deserialize, Serialize};
use serde_json::Value; use serde_json::Value;
use std::collections::HashMap; use std::collections::HashMap;
use std::path::Path; use std::path::Path;
use uuid::Uuid;
use crate::config::{ use crate::config::{
copy_file, delete_file, get_provider_config_path, read_json_file, write_json_file, copy_file, delete_file, get_provider_config_path, read_json_file, write_json_file,
@@ -22,16 +21,6 @@ pub struct Provider {
} }
impl 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创建供应商 /// 从现有ID创建供应商
pub fn with_id(id: String, name: String, settings_config: Value, website_url: Option<String>) -> Self { pub fn with_id(id: String, name: String, settings_config: Value, website_url: Option<String>) -> Self {
Self { Self {
@@ -170,15 +159,6 @@ impl ProviderManager {
Ok(()) 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> { pub fn get_all_providers(&self) -> &HashMap<String, Provider> {
&self.providers &self.providers

View File

@@ -31,15 +31,5 @@ impl AppState {
manager.save_to_file(&config_path) 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(())
}
}