use tauri::State; use tauri_helper::auto_collect_command; use crate::models::METING_API_URL; use crate::{ models::ApiResponse, services::http::{ApiEndpoint, HttpClient}, }; #[tauri::command] #[auto_collect_command] pub async fn music_url( state: State<'_, HttpClient>, id: String, server: String, type_: String, ) -> Result, String> { let client = reqwest::Client::new(); let params = vec![ ("id".to_string(), id), ("server".to_string(), server), ("type".to_string(), type_), ]; let resp = client .get(format!("{}/api", METING_API_URL)) .query(¶ms) .send() .await .map_err(|e| e.to_string())?; let data = resp.json().await.map_err(|e| e.to_string())?; Ok(ApiResponse::success(data)) }