mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2024-11-16 03:32:36 +08:00
chore: update
This commit is contained in:
parent
7b11e157c4
commit
ae1c6d4617
|
@ -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(())
|
||||
}
|
||||
|
|
|
@ -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(_) => {
|
||||
|
|
|
@ -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::<QueryParam>())
|
||||
.and_then(scheme_handler);
|
||||
|
||||
async fn scheme_handler(_: QueryParam) -> Result<impl warp::Reply, Infallible> {
|
||||
//let _ = resolve::resolve_scheme(query.param).await;
|
||||
Ok(warp::reply::with_status("Ok", StatusCode::OK))
|
||||
async fn scheme_handler(query: QueryParam) -> Result<impl warp::Reply, Infallible> {
|
||||
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;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user