mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-12-01 10:40:14 +08:00
refactor(config): centralize Mihomo YAML output
This commit is contained in:
@@ -2,7 +2,7 @@ use super::{CoreManager, PROFILE_SELECTIONS_PENDING_COMMIT, RunningMode};
|
||||
use crate::core::notify::NoticeStatus;
|
||||
use crate::core::service::StageRequest;
|
||||
use crate::{
|
||||
config::{Config, IProfiles, profiles::save_profiles, runtime::IRuntime},
|
||||
config::{Config, IProfiles, mihomo_yaml, profiles::save_profiles, runtime::IRuntime},
|
||||
constants::timing,
|
||||
core::{
|
||||
handle,
|
||||
@@ -170,7 +170,8 @@ impl CoreManager {
|
||||
}
|
||||
});
|
||||
|
||||
help::save_yaml(&runtime_path, &clash_config, Some("# Clash Verge Runtime")).await?;
|
||||
let yaml = mihomo_yaml::serialize(clash_config)?;
|
||||
help::save_yaml_str(&runtime_path, &yaml, Some("# Clash Verge Runtime")).await?;
|
||||
handle::Handle::notice(status, message);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ pub(super) fn explain_core_occupancy(error: anyhow::Error) -> anyhow::Error {
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
fn sidecar_config_without_tun(yaml: &str) -> Result<std::string::String> {
|
||||
use crate::config::mihomo_yaml;
|
||||
use serde_yaml_ng::{Mapping, Value};
|
||||
|
||||
let mut config: Mapping = serde_yaml_ng::from_str(yaml)?;
|
||||
@@ -47,7 +48,7 @@ fn sidecar_config_without_tun(yaml: &str) -> Result<std::string::String> {
|
||||
tun.as_mapping_mut()
|
||||
.context("invalid Sidecar TUN configuration")?
|
||||
.insert(Value::from("enable"), Value::Bool(false));
|
||||
Ok(serde_yaml_ng::to_string(&config)?)
|
||||
Ok(mihomo_yaml::serialize(&config)?)
|
||||
}
|
||||
|
||||
const SIDECAR_READINESS_ATTEMPTS: usize = 30;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::core::notify::NoticeStatus;
|
||||
use crate::utils::dirs;
|
||||
use crate::{
|
||||
config::{Config, runtime::IRuntime},
|
||||
config::{Config, mihomo_yaml, runtime::IRuntime},
|
||||
constants,
|
||||
core::{
|
||||
CoreManager,
|
||||
@@ -613,7 +613,7 @@ async fn collect_service_runtime_bundle(config_file: &Path) -> Result<RuntimeBun
|
||||
let bin_path = service_core_path(&clash_core, bin_ext)?;
|
||||
let plan = collect_runtime_bundle(config_file).await?;
|
||||
Ok(RuntimeBundle {
|
||||
yaml: plan.yaml,
|
||||
yaml: mihomo_yaml::serialize(&plan.config).context("failed to serialize service runtime config")?,
|
||||
assets: plan
|
||||
.assets
|
||||
.into_iter()
|
||||
|
||||
Reference in New Issue
Block a user