feat: ensure Mihomo and Verge services are running before executing commands

This commit is contained in:
Tunglies
2025-03-22 16:59:32 +08:00
parent 86f69fd574
commit 1d88d98ea1
4 changed files with 81 additions and 51 deletions

View File

@@ -98,6 +98,12 @@ impl MihomoManager {
}
impl MihomoManager {
pub async fn is_mihomo_running(&self) -> Result<(), String> {
let url = format!("{}/version", self.mihomo_server);
let _response = self.send_request(Method::GET, url, None).await?;
Ok(())
}
pub async fn put_configs_force(&self, clash_config_path: &str) -> Result<(), String> {
let url = format!("{}/configs?force=true", self.mihomo_server);
let payload = serde_json::json!({