refactor: done

This commit is contained in:
GyDi
2022-11-18 18:18:41 +08:00
parent 34daffbc96
commit 2667ed13f1
24 changed files with 343 additions and 341 deletions

View File

@@ -1,4 +1,4 @@
use crate::utils::{config, dirs};
use crate::utils::{dirs, help};
use anyhow::Result;
use serde::{Deserialize, Serialize};
use serde_yaml::{Mapping, Value};
@@ -8,7 +8,7 @@ pub struct IClashTemp(pub Mapping);
impl IClashTemp {
pub fn new() -> Self {
match dirs::clash_path().and_then(|path| config::read_merge_mapping(&path)) {
match dirs::clash_path().and_then(|path| help::read_merge_mapping(&path)) {
Ok(map) => Self(map),
Err(err) => {
log::error!(target: "app", "{err}");
@@ -20,7 +20,7 @@ impl IClashTemp {
pub fn template() -> Self {
let mut map = Mapping::new();
map.insert("mixed-port".into(), 7892.into());
map.insert("mixed-port".into(), 7890.into());
map.insert("log-level".into(), "info".into());
map.insert("allow-lan".into(), false.into());
map.insert("mode".into(), "rule".into());
@@ -37,10 +37,10 @@ impl IClashTemp {
}
pub fn save_config(&self) -> Result<()> {
config::save_yaml(
dirs::clash_path()?,
help::save_yaml(
&dirs::clash_path()?,
&self.0,
Some("# Default Config For ClashN Core\n\n"),
Some("# Generated by Clash Verge"),
)
}