Skip to content

Commit

Permalink
fix: use if let instead
Browse files Browse the repository at this point in the history
  • Loading branch information
greenhat616 committed Jan 22, 2024
1 parent 1ed3905 commit f0a6d6d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
25 changes: 11 additions & 14 deletions backend/tauri/src/config/prfitem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,21 +195,18 @@ impl PrfItem {
}
// 使用系统代理
else if with_proxy {
match Sysproxy::get_system_proxy() {
Ok(p @ Sysproxy { enable: true, .. }) => {
let proxy_scheme = format!("http://{}:{}", p.host, p.port);

if let Ok(proxy) = reqwest::Proxy::http(&proxy_scheme) {
builder = builder.proxy(proxy);
}
if let Ok(proxy) = reqwest::Proxy::https(&proxy_scheme) {
builder = builder.proxy(proxy);
}
if let Ok(proxy) = reqwest::Proxy::all(&proxy_scheme) {
builder = builder.proxy(proxy);
}
if let Ok(p @ Sysproxy { enable: true, .. }) = Sysproxy::get_system_proxy() {
let proxy_scheme = format!("http://{}:{}", p.host, p.port);

if let Ok(proxy) = reqwest::Proxy::http(&proxy_scheme) {
builder = builder.proxy(proxy);
}
if let Ok(proxy) = reqwest::Proxy::https(&proxy_scheme) {
builder = builder.proxy(proxy);
}
if let Ok(proxy) = reqwest::Proxy::all(&proxy_scheme) {
builder = builder.proxy(proxy);
}
_ => todo!(),
};
}

Expand Down
7 changes: 3 additions & 4 deletions backend/tauri/src/enhance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,15 @@ pub fn enhance() -> (Mapping, Vec<String>, HashMap<String, ResultLog>) {
.for_each(|item| {
log::debug!(target: "app", "run builtin script {}", item.uid);

match item.data {
ChainType::Script(script) => match use_script(script, config.to_owned()) {
if let ChainType::Script(script) = item.data {
match use_script(script, config.to_owned()) {
Ok((res_config, _)) => {
config = use_filter(res_config, &clash_fields, enable_filter);
}
Err(err) => {
log::error!(target: "app", "builtin script error `{err}`");
}
},
ChainType::Merge(_) => todo!(),
}
}
});
}
Expand Down

0 comments on commit f0a6d6d

Please sign in to comment.