mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 08:45:41 +08:00
refactor(Draft): Replace latest() with latest_ref() and data() with data_mut() in multiple files for improved mutability handling and consistency across the codebase (#3987)
* feat: add benchmarking for draft operations and new draft management structure * Refactor Config Access: Replace `latest()` with `latest_ref()` and `data()` with `data_mut()` in multiple files for improved mutability handling and consistency across the codebase. * refactor: remove DraftNew implementation and related benchmarks for cleaner codebase
This commit is contained in:
@@ -32,7 +32,7 @@ pub struct ServiceState {
|
||||
impl ServiceState {
|
||||
// 获取当前的服务状态
|
||||
pub fn get() -> Self {
|
||||
if let Some(state) = Config::verge().latest().service_state.clone() {
|
||||
if let Some(state) = Config::verge().latest_ref().service_state.clone() {
|
||||
return state;
|
||||
}
|
||||
Self::default()
|
||||
@@ -41,11 +41,11 @@ impl ServiceState {
|
||||
// 保存服务状态
|
||||
pub fn save(&self) -> Result<()> {
|
||||
let config = Config::verge();
|
||||
let mut latest = config.latest().clone();
|
||||
let mut latest = config.latest_ref().clone();
|
||||
latest.service_state = Some(self.clone());
|
||||
*config.draft() = latest;
|
||||
*config.draft_mut() = latest;
|
||||
config.apply();
|
||||
let result = config.latest().save_file();
|
||||
let result = config.latest_ref().save_file();
|
||||
result
|
||||
}
|
||||
|
||||
@@ -741,7 +741,7 @@ pub(super) async fn start_with_existing_service(config_file: &PathBuf) -> Result
|
||||
log::info!(target:"app", "尝试使用现有服务启动核心 (IPC)");
|
||||
// logging!(info, Type::Service, true, "尝试使用现有服务启动核心");
|
||||
|
||||
let clash_core = Config::verge().latest().get_valid_clash_core();
|
||||
let clash_core = Config::verge().latest_ref().get_valid_clash_core();
|
||||
|
||||
let bin_ext = if cfg!(windows) { ".exe" } else { "" };
|
||||
let clash_bin = format!("{clash_core}{bin_ext}");
|
||||
|
||||
Reference in New Issue
Block a user