//! 代理服务相关的 Tauri 命令 //! //! 提供前端调用的 API 接口 use crate::proxy::types::*; use crate::store::AppState; /// 启动代理服务器 #[tauri::command] pub async fn start_proxy_server( state: tauri::State<'_, AppState>, ) -> Result { state.proxy_service.start().await } /// 停止代理服务器 #[tauri::command] pub async fn stop_proxy_server(state: tauri::State<'_, AppState>) -> Result<(), String> { state.proxy_service.stop().await } /// 获取代理服务器状态 #[tauri::command] pub async fn get_proxy_status(state: tauri::State<'_, AppState>) -> Result { state.proxy_service.get_status().await } /// 获取代理配置 #[tauri::command] pub async fn get_proxy_config(state: tauri::State<'_, AppState>) -> Result { state.proxy_service.get_config().await } /// 更新代理配置 #[tauri::command] pub async fn update_proxy_config( state: tauri::State<'_, AppState>, config: ProxyConfig, ) -> Result<(), String> { state.proxy_service.update_config(&config).await } /// 检查代理服务器是否正在运行 #[tauri::command] pub async fn is_proxy_running(state: tauri::State<'_, AppState>) -> Result { Ok(state.proxy_service.is_running().await) }