feat(mihomo): refactor MihomoManager for global access and improve proxy retrieval (#2906)

This commit is contained in:
Tunglies
2025-03-05 10:58:54 +08:00
committed by GitHub
parent ebb194d2a2
commit 6c96724dce
4 changed files with 46 additions and 13 deletions

View File

@@ -1,21 +1,16 @@
use super::CmdResult;
use crate::core;
use mihomo_api;
use crate::module::mihomo::MihomoManager;
#[tauri::command]
pub async fn get_proxies() -> CmdResult<serde_json::Value> {
let (mihomo_server, headers) = core::clash_api::clash_client_info().unwrap();
let mihomo = mihomo_api::MihomoManager::new(mihomo_server, headers);
Ok(mihomo.refresh_proxies().await.unwrap().get_proxies())
let mannager = MihomoManager::global();
mannager.refresh_proxies().await.unwrap();
Ok(mannager.get_proxies())
}
#[tauri::command]
pub async fn get_providers_proxies() -> CmdResult<serde_json::Value> {
let (mihomo_server, headers) = core::clash_api::clash_client_info().unwrap();
let mihomo = mihomo_api::MihomoManager::new(mihomo_server, headers);
Ok(mihomo
.refresh_providers_proxies()
.await
.unwrap()
.get_providers_proxies())
let mannager = MihomoManager::global();
mannager.refresh_providers_proxies().await.unwrap();
Ok(mannager.get_providers_proxies())
}