refactor: simplify proxy type handling and improve error handling in network commands

This commit is contained in:
Tunglies
2025-05-16 00:09:34 +08:00
parent 92ae277e3a
commit 53a46d0dc6
11 changed files with 30 additions and 35 deletions

View File

@@ -8,7 +8,7 @@ use tokio::task::spawn_blocking;
/// get the system proxy
#[tauri::command]
pub async fn get_sys_proxy() -> CmdResult<Mapping> {
let current = spawn_blocking(move || Sysproxy::get_system_proxy())
let current = spawn_blocking(Sysproxy::get_system_proxy)
.await
.map_err(|e| format!("Failed to spawn blocking task for sysproxy: {}", e))?
.map_err(|e| format!("Failed to get system proxy: {}", e))?;
@@ -27,7 +27,7 @@ pub async fn get_sys_proxy() -> CmdResult<Mapping> {
/// get the system proxy
#[tauri::command]
pub async fn get_auto_proxy() -> CmdResult<Mapping> {
let current = spawn_blocking(move || Autoproxy::get_auto_proxy())
let current = spawn_blocking(Autoproxy::get_auto_proxy)
.await
.map_err(|e| format!("Failed to spawn blocking task for autoproxy: {}", e))?
.map_err(|e| format!("Failed to get auto proxy: {}", e))?;