From c62dddd5b9f1ac8c6f1827f981508bcb3a7e57ff Mon Sep 17 00:00:00 2001 From: GyDi Date: Thu, 24 Nov 2022 17:52:25 +0800 Subject: [PATCH] feat: save some fields in the runtime config, close #292 --- src-tauri/src/config/runtime.rs | 13 +++++++++++++ src-tauri/src/feat.rs | 2 ++ 2 files changed, 15 insertions(+) diff --git a/src-tauri/src/config/runtime.rs b/src-tauri/src/config/runtime.rs index 3b67b06..cce376b 100644 --- a/src-tauri/src/config/runtime.rs +++ b/src-tauri/src/config/runtime.rs @@ -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()); + } + }); + } + } } diff --git a/src-tauri/src/feat.rs b/src-tauri/src/feat.rs index 7ae48ca..1e49117 100644 --- a/src-tauri/src/feat.rs +++ b/src-tauri/src/feat.rs @@ -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); + >::Ok(()) } { Ok(()) => {