mirror of
https://github.com/OpenListTeam/OpenList-Desktop.git
synced 2025-11-25 03:14:56 +08:00
* feat: add save_settings_with_update_port command and update related components * refactor: remove state parameter from API key retrieval and update related functions * feat: enhance release workflow with tag validation and improve build scripts * feat: update release workflow to use version input from auto-version workflow * 📦 Chore(custom): add Clippy configuration for consistent linting across platforms * chore: add Clippy configuration for consistent linting across platforms * 🐛 Fix(custom): fix ci * 🚧 WIP(custom): fix clippy error * 🐛 Fix(custom): add default openlist and rclone version * 🚧 WIP(custom): fix clippy errors * 🚧 WIP(custom): fix clippy errors * 🐛 Fix(custom): fix ci bugs
48 lines
1.5 KiB
Rust
48 lines
1.5 KiB
Rust
use crate::core::service::check_service_status as check_service_status_impl;
|
|
use crate::core::service::install_service as install_service_impl;
|
|
use crate::core::service::start_service as start_service_impl;
|
|
|
|
use crate::core::service::uninstall_service as uninstall_service_impl;
|
|
use crate::object::structs::AppState;
|
|
use crate::utils::api::{get_api_key, get_server_port};
|
|
use reqwest;
|
|
use tauri::State;
|
|
|
|
#[tauri::command]
|
|
pub async fn check_service_status() -> Result<String, String> {
|
|
check_service_status_impl().await.map_err(|e| e.to_string())
|
|
}
|
|
|
|
#[tauri::command]
|
|
pub async fn install_service() -> Result<bool, String> {
|
|
install_service_impl().await.map_err(|e| e.to_string())
|
|
}
|
|
|
|
#[tauri::command]
|
|
pub async fn uninstall_service() -> Result<bool, String> {
|
|
uninstall_service_impl().await.map_err(|e| e.to_string())
|
|
}
|
|
|
|
#[tauri::command]
|
|
pub async fn stop_service(_state: State<'_, AppState>) -> Result<bool, String> {
|
|
let api_key = get_api_key();
|
|
let port = get_server_port();
|
|
let client = reqwest::Client::new();
|
|
let response = client
|
|
.post(format!("http://127.0.0.1:{port}/api/v1/service/stop"))
|
|
.header("Authorization", format!("Bearer {api_key}"))
|
|
.send()
|
|
.await
|
|
.map_err(|e| format!("Failed to send request: {e}"))?;
|
|
if response.status().is_success() {
|
|
Ok(true)
|
|
} else {
|
|
Err(format!("Failed to stop service: {}", response.status()))
|
|
}
|
|
}
|
|
|
|
#[tauri::command]
|
|
pub async fn start_service() -> Result<bool, String> {
|
|
start_service_impl().await.map_err(|e| e.to_string())
|
|
}
|