Ver Fonte

chore: Auto Update config.yml

MystiPanda há 1 ano atrás
pai
commit
27305317ce
1 ficheiros alterados com 10 adições e 2 exclusões
  1. 10 2
      src-tauri/src/config/clash.rs

+ 10 - 2
src-tauri/src/config/clash.rs

@@ -12,11 +12,19 @@ pub struct IClashTemp(pub Mapping);
 
 impl IClashTemp {
     pub fn new() -> Self {
+        let template = Self::template();
         match dirs::clash_path().and_then(|path| help::read_merge_mapping(&path)) {
-            Ok(map) => Self(Self::guard(map)),
+            Ok(mut map) => {
+                template.0.keys().for_each(|key| {
+                    if !map.contains_key(key) {
+                        map.insert(key.clone(), template.0.get(key).unwrap().clone());
+                    }
+                });
+                Self(Self::guard(map))
+            }
             Err(err) => {
                 log::error!(target: "app", "{err}");
-                Self::template()
+                template
             }
         }
     }