mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 17:15:38 +08:00
feat: manage clash config
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
use crate::utils::dirs;
|
||||
use serde::{de::DeserializeOwned, Serialize};
|
||||
use serde_yaml::Mapping;
|
||||
use std::{fs, path::PathBuf};
|
||||
|
||||
/// read data from yaml as struct T
|
||||
@@ -32,17 +30,3 @@ pub fn save_yaml<T: Serialize>(
|
||||
Err(_) => Err("can not convert the data to yaml".into()),
|
||||
}
|
||||
}
|
||||
|
||||
/// Get Clash Core Config `config.yaml`
|
||||
pub fn read_clash() -> Mapping {
|
||||
read_yaml::<Mapping>(dirs::app_home_dir().join("config.yaml"))
|
||||
}
|
||||
|
||||
/// Save the clash core Config `config.yaml`
|
||||
pub fn save_clash(config: &Mapping) -> Result<(), String> {
|
||||
save_yaml(
|
||||
dirs::app_home_dir().join("config.yaml"),
|
||||
config,
|
||||
Some("# Default Config For Clash Core\n\n"),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ pub fn resolve_setup(app: &App) {
|
||||
}
|
||||
|
||||
*profiles = ProfilesConfig::read_file();
|
||||
if let Err(err) = profiles.activate(clash.info.clone()) {
|
||||
if let Err(err) = profiles.activate(&clash) {
|
||||
log::error!("{}", err);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user