chore: update

This commit is contained in:
huzibaca 2024-10-10 18:40:39 +08:00
parent 045ddc5ca5
commit d14bda7e7a
No known key found for this signature in database
GPG Key ID: D4364EE4851DC302
3 changed files with 13 additions and 13 deletions

View File

@ -41,14 +41,14 @@ fn get_bypass() -> String {
None => "".to_string(), None => "".to_string(),
}; };
let bypass = if custom_bypass.is_empty() {
if custom_bypass.is_empty() {
DEFAULT_BYPASS.to_string() DEFAULT_BYPASS.to_string()
} else if use_default { } else if use_default {
format!("{},{}", DEFAULT_BYPASS, custom_bypass) format!("{},{}", DEFAULT_BYPASS, custom_bypass)
} else { } else {
custom_bypass custom_bypass
}; }
bypass
} }
impl Sysopt { impl Sysopt {
@ -311,7 +311,7 @@ impl Sysopt {
let sysproxy = Sysproxy::get_system_proxy(); let sysproxy = Sysproxy::get_system_proxy();
let autoproxy = Autoproxy::get_auto_proxy(); let autoproxy = Autoproxy::get_auto_proxy();
if !sysproxy.is_ok() || !autoproxy.is_ok() { if sysproxy.is_err() || autoproxy.is_err() {
log::error!(target: "app", "failed to get the system proxy"); log::error!(target: "app", "failed to get the system proxy");
continue; continue;
} }
@ -367,23 +367,23 @@ impl Sysopt {
let shell = app_handle.shell(); let shell = app_handle.shell();
let output = if pac { let output = if pac {
let address = format!("http://{}:{}/pac", "127.0.0.1", pac_port); let address = format!("http://{}:{}/pac", "127.0.0.1", pac_port);
let output = shell
shell
.command(sysproxy_exe.as_path().to_str().unwrap()) .command(sysproxy_exe.as_path().to_str().unwrap())
.args(["opac", address.as_str()]) .args(["opac", address.as_str()])
.output() .output()
.await .await
.unwrap(); .unwrap()
output
} else { } else {
let address = format!("{}:{}", "127.0.0.1", port); let address = format!("{}:{}", "127.0.0.1", port);
let bypass = get_bypass(); let bypass = get_bypass();
let output = shell
shell
.command(sysproxy_exe.as_path().to_str().unwrap()) .command(sysproxy_exe.as_path().to_str().unwrap())
.args(["global", address.as_str(), bypass.as_ref()]) .args(["global", address.as_str(), bypass.as_ref()])
.output() .output()
.await .await
.unwrap(); .unwrap()
output
}; };
if !output.status.success() { if !output.status.success() {
break; break;

View File

@ -26,5 +26,5 @@ pub async fn use_tun(mut config: Mapping) -> Mapping {
}); });
revise!(tun_val, "enable", true); revise!(tun_val, "enable", true);
revise!(config, "tun", tun_val); revise!(config, "tun", tun_val);
return config; config
} }

View File

@ -250,11 +250,11 @@ pub async fn patch_verge(patch: IVerge) -> Result<()> {
Config::verge().apply(); Config::verge().apply();
Config::verge().data().save_file()?; Config::verge().data().save_file()?;
return Ok(()); Ok(())
} }
Err(err) => { Err(err) => {
Config::verge().discard(); Config::verge().discard();
return Err(err); Err(err)
} }
} }
} }