diff --git a/src-tauri/src/utils/init.rs b/src-tauri/src/utils/init.rs index 3d50d6c..621450a 100644 --- a/src-tauri/src/utils/init.rs +++ b/src-tauri/src/utils/init.rs @@ -313,7 +313,10 @@ pub async fn startup_script(app_handle: &AppHandle) -> Result<()> { } else if script_path.ends_with(".ps1") || script_path.ends_with(".bat") { "powershell" } else { - return Err(anyhow::anyhow!("unsupported script extension: {}", script_path)); + return Err(anyhow::anyhow!( + "unsupported script extension: {}", + script_path + )); }; let script_dir = PathBuf::from(&script_path); @@ -329,7 +332,8 @@ pub async fn startup_script(app_handle: &AppHandle) -> Result<()> { .command(shell_type) .current_dir(working_dir.to_path_buf()) .args(&[script_path]) - .output().await?; + .output() + .await?; Ok(()) } diff --git a/src-tauri/src/utils/resolve.rs b/src-tauri/src/utils/resolve.rs index d97fdcb..f7860f6 100644 --- a/src-tauri/src/utils/resolve.rs +++ b/src-tauri/src/utils/resolve.rs @@ -243,7 +243,7 @@ pub async fn resolve_scheme(param: String) -> Result<()> { .trim_start_matches("clash://install-config?url="); let handle = handle::Handle::global(); - let app_handle = handle.app_handle.lock(); + let app_handle = handle.app_handle.lock().clone(); if let Some(app_handle) = app_handle.as_ref() { match import_profile(url.to_string(), None).await { Ok(_) => { diff --git a/src-tauri/src/utils/server.rs b/src-tauri/src/utils/server.rs index 64a00a3..3090da3 100644 --- a/src-tauri/src/utils/server.rs +++ b/src-tauri/src/utils/server.rs @@ -10,7 +10,9 @@ use warp::http::StatusCode; use warp::Filter; #[derive(serde::Deserialize, Debug)] -struct QueryParam {} +struct QueryParam { + param: String, +} /// check whether there is already exists pub async fn check_singleton() -> Result<()> { @@ -84,10 +86,16 @@ pub fn embed_server(app_handle: &AppHandle) { .and(warp::query::()) .and_then(scheme_handler); - async fn scheme_handler(_: QueryParam) -> Result { - //let _ = resolve::resolve_scheme(query.param).await; - Ok(warp::reply::with_status("Ok", StatusCode::OK)) + async fn scheme_handler(query: QueryParam) -> Result { + let result = resolve::resolve_scheme(query.param).await; + Ok(match result { + Ok(_) => warp::reply::with_status("Ok", StatusCode::OK), + Err(_) => { + warp::reply::with_status("Internal Error", StatusCode::INTERNAL_SERVER_ERROR) + } + }) } + let commands = ping.or(visible).or(pac).or(scheme); warp::serve(commands).run(([127, 0, 0, 1], port)).await; });