feat: save some fields in the runtime config, close #292

This commit is contained in:
GyDi 2022-11-24 17:52:25 +08:00
parent 490ba9f140
commit c62dddd5b9
No known key found for this signature in database
GPG Key ID: 9C3AD40F1F99880A
2 changed files with 15 additions and 0 deletions

View File

@ -15,4 +15,17 @@ impl IRuntime {
pub fn new() -> Self {
Self::default()
}
// 这里只更改 allow-lan | ipv6 | log-level
pub fn patch_config(&mut self, patch: Mapping) {
if let Some(config) = self.config.as_mut() {
["allow-lan", "ipv6", "log-level"]
.into_iter()
.for_each(|key| {
if let Some(value) = patch.get(key).to_owned() {
config.insert(key.into(), value.clone());
}
});
}
}
}

View File

@ -183,6 +183,8 @@ pub async fn patch_clash(patch: Mapping) -> Result<()> {
log_err!(handle::Handle::update_systray_part());
}
Config::runtime().latest().patch_config(patch);
<Result<()>>::Ok(())
} {
Ok(()) => {