refactor: streamline config handling and logging mechanisms

This commit is contained in:
Tunglies
2025-11-15 02:46:34 +08:00
parent f6f288f02b
commit 2b0ba4dc95
6 changed files with 17 additions and 108 deletions

View File

@@ -1,9 +1,6 @@
use super::CmdResult;
use crate::{
cmd::StringifyErr as _,
config::{Config, ConfigType},
core::CoreManager,
log_err,
cmd::StringifyErr as _, config::Config, core::CoreManager, logging_error, utils::logging::Type,
};
use anyhow::{Context as _, anyhow};
use serde_yaml_ng::Mapping;
@@ -104,14 +101,9 @@ pub async fn update_proxy_chain_config_in_runtime(
{
let runtime = Config::runtime().await;
runtime.edit_draft(|d| d.update_proxy_chain_config(proxy_chain_config));
runtime.apply();
// 我们需要在 CoreManager 中验证并应用配置,这里不应该直接调用 runtime.apply()
}
// 生成新的运行配置文件并通知 Clash 核心重新加载
let run_path = Config::generate_file(ConfigType::Run)
.await
.stringify_err()?;
log_err!(CoreManager::global().put_configs_force(run_path).await);
logging_error!(Type::Core, CoreManager::global().update_config().await);
Ok(())
}