mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 04:53:44 +08:00
fix: code lint
This commit is contained in:
parent
d9e5387bff
commit
57f1c005e6
@ -337,7 +337,7 @@ pub fn get_network_interfaces() -> Vec<String> {
|
||||
for (interface_name, _) in &networks {
|
||||
result.push(interface_name.clone());
|
||||
}
|
||||
return result;
|
||||
result
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
|
@ -137,7 +137,7 @@ pub async fn install_service(passwd: String) -> Result<()> {
|
||||
.output()?;
|
||||
let output = sudo(
|
||||
&passwd,
|
||||
format!("{}", installer_path.to_string_lossy().replace(" ", "\\ ")),
|
||||
installer_path.to_string_lossy().replace(" ", "\\ ").to_string(),
|
||||
)
|
||||
.output()?;
|
||||
|
||||
@ -244,7 +244,7 @@ pub async fn uninstall_service(passwd: String) -> Result<()> {
|
||||
.output()?;
|
||||
let output = sudo(
|
||||
&passwd,
|
||||
format!("{}", uninstaller_path.to_string_lossy().replace(" ", "\\ ")),
|
||||
uninstaller_path.to_string_lossy().replace(" ", "\\ ").to_string(),
|
||||
)
|
||||
.output()?;
|
||||
|
||||
|
@ -66,12 +66,10 @@ fn get_bypass() -> String {
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
let bypass = if custom_bypass.is_empty() {
|
||||
DEFAULT_BYPASS.to_string()
|
||||
} else {
|
||||
if use_default {
|
||||
} else if use_default {
|
||||
format!("{},{}", DEFAULT_BYPASS, custom_bypass)
|
||||
} else {
|
||||
custom_bypass
|
||||
}
|
||||
};
|
||||
|
||||
bypass
|
||||
|
@ -12,7 +12,7 @@ pub fn use_seq(seq_map: SeqMap, config: Mapping, name: &str) -> Mapping {
|
||||
let append = seq_map.append;
|
||||
let delete = seq_map.delete;
|
||||
|
||||
let origin_seq = config.get(&name).map_or(Sequence::default(), |val| {
|
||||
let origin_seq = config.get(name).map_or(Sequence::default(), |val| {
|
||||
val.as_sequence().unwrap_or(&Sequence::default()).clone()
|
||||
});
|
||||
let mut seq = origin_seq.clone();
|
||||
@ -23,7 +23,7 @@ pub fn use_seq(seq_map: SeqMap, config: Mapping, name: &str) -> Mapping {
|
||||
if let Some(name) = if item.is_string() {
|
||||
Some(item)
|
||||
} else {
|
||||
item.get("name").map(|y| y.clone())
|
||||
item.get("name").cloned()
|
||||
} {
|
||||
delete_names.push(name.clone());
|
||||
}
|
||||
@ -34,7 +34,7 @@ pub fn use_seq(seq_map: SeqMap, config: Mapping, name: &str) -> Mapping {
|
||||
} else {
|
||||
x.get("name")
|
||||
} {
|
||||
!delete_names.contains(&x_name)
|
||||
!delete_names.contains(x_name)
|
||||
} else {
|
||||
true
|
||||
}
|
||||
@ -51,5 +51,5 @@ pub fn use_seq(seq_map: SeqMap, config: Mapping, name: &str) -> Mapping {
|
||||
|
||||
let mut config = config.clone();
|
||||
config.insert(Value::from(name), Value::from(seq));
|
||||
return config;
|
||||
config
|
||||
}
|
||||
|
@ -184,13 +184,11 @@ pub async fn patch_verge(patch: IVerge) -> Result<()> {
|
||||
update_core_config().await?;
|
||||
}
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
if redir_enabled.is_some() || redir_port.is_some() {
|
||||
if !generated {
|
||||
if (redir_enabled.is_some() || redir_port.is_some()) && !generated {
|
||||
Config::generate().await?;
|
||||
CoreManager::global().run_core().await?;
|
||||
generated = true;
|
||||
}
|
||||
}
|
||||
#[cfg(target_os = "linux")]
|
||||
if tproxy_enabled.is_some() || tproxy_port.is_some() {
|
||||
if !generated {
|
||||
@ -199,17 +197,13 @@ pub async fn patch_verge(patch: IVerge) -> Result<()> {
|
||||
generated = true;
|
||||
}
|
||||
}
|
||||
if socks_enabled.is_some()
|
||||
if (socks_enabled.is_some()
|
||||
|| http_enabled.is_some()
|
||||
|| socks_port.is_some()
|
||||
|| http_port.is_some()
|
||||
|| mixed_port.is_some()
|
||||
{
|
||||
if !generated {
|
||||
|| http_port.is_some() || mixed_port.is_some()) && !generated {
|
||||
Config::generate().await?;
|
||||
CoreManager::global().run_core().await?;
|
||||
}
|
||||
}
|
||||
if auto_launch.is_some() {
|
||||
sysopt::Sysopt::global().update_launch()?;
|
||||
}
|
||||
|
@ -48,11 +48,11 @@ pub fn app_home_dir() -> Result<PathBuf> {
|
||||
|
||||
match app_handle.path().data_dir() {
|
||||
Ok(dir) => {
|
||||
return Ok(dir.join(APP_ID));
|
||||
Ok(dir.join(APP_ID))
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("Failed to get the app home directory: {}", e);
|
||||
return Err(anyhow::anyhow!("Failed to get the app homedirectory"));
|
||||
Err(anyhow::anyhow!("Failed to get the app homedirectory"))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -62,13 +62,13 @@ pub fn app_resources_dir() -> Result<PathBuf> {
|
||||
let app_handle = handle::Handle::global().app_handle().unwrap();
|
||||
match app_handle.path().resource_dir() {
|
||||
Ok(dir) => {
|
||||
return Ok(dir.join("resources"));
|
||||
Ok(dir.join("resources"))
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("Failed to get the resource directory: {}", e);
|
||||
return Err(anyhow::anyhow!("Failed to get the resource directory"));
|
||||
Err(anyhow::anyhow!("Failed to get the resource directory"))
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// profiles dir
|
||||
|
@ -332,7 +332,7 @@ pub async fn startup_script() -> Result<()> {
|
||||
app_handle
|
||||
.shell()
|
||||
.command(shell_type)
|
||||
.current_dir(working_dir.to_path_buf())
|
||||
.current_dir(working_dir)
|
||||
.args(&[script_path])
|
||||
.output()
|
||||
.await?;
|
||||
|
Loading…
x
Reference in New Issue
Block a user