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:
30
src-tauri/Cargo.lock
generated
30
src-tauri/Cargo.lock
generated
@@ -103,8 +103,6 @@ dependencies = [
|
||||
"tauri-plugin-log",
|
||||
"tauri-plugin-opener",
|
||||
"tauri-plugin-shell",
|
||||
"tauri-plugin-store",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4180,22 +4178,6 @@ dependencies = [
|
||||
"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]]
|
||||
name = "tauri-runtime"
|
||||
version = "2.8.0"
|
||||
@@ -4432,21 +4414,9 @@ dependencies = [
|
||||
"pin-project-lite",
|
||||
"slab",
|
||||
"socket2",
|
||||
"tokio-macros",
|
||||
"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]]
|
||||
name = "tokio-util"
|
||||
version = "0.7.16"
|
||||
|
||||
@@ -23,8 +23,6 @@ serde = { version = "1.0", features = ["derive"] }
|
||||
log = "0.4"
|
||||
tauri = { version = "2.8.2", features = [] }
|
||||
tauri-plugin-log = "2"
|
||||
tauri-plugin-store = "2"
|
||||
tauri-plugin-shell = "2"
|
||||
tauri-plugin-opener = "2"
|
||||
dirs = "5.0"
|
||||
uuid = { version = "1.11", features = ["v4", "serde"] }
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
"permissions": [
|
||||
"core:default",
|
||||
"shell:allow-open",
|
||||
"shell:allow-execute",
|
||||
"opener:default"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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