mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-27 16:22:11 +08:00
* feat: update service installation scripts and IPC integration - Updated `Cargo.toml` to use version 2.0.8 of `clash_verge_service_ipc` with "client" feature. - Renamed service installation and uninstallation scripts in `post-install.sh` and `pre-remove.sh`. - Removed `service_ipc` module and refactored IPC handling in `service.rs` to use the new `clash_verge_service_ipc` directly. - Adjusted service version checking and core management to align with the new IPC structure. - Simplified directory checks in `dirs.rs` and updated logging configurations in `init.rs`. - Updated Linux configuration file to reflect new script names. - Enhanced service installer hook to manage state more effectively. * refactor: simplify ClashConfig instantiation and remove unused service log file function * feat: update clash_verge_service_ipc to version 2.0.9 and enhance service initialization logging * chore: update clash_verge_service_ipc to version 2.0.10 and refactor async service manager initialization * fix: update clash_verge_service_ipc to version 2.0.11 and improve service manager initialization * fix: increase sleep duration for socket readiness check to improve stability * fix: update clash_verge_service_ipc to version 2.0.12 and kode-bridge to version 0.3.4; refactor service management and IPC path checks * fix: update clash_verge_service_ipc to version 2.0.13; refactor service connection and initialization logic
47 lines
1.2 KiB
Rust
47 lines
1.2 KiB
Rust
use super::CmdResult;
|
|
use crate::{
|
|
core::service::{self, SERVICE_MANAGER, ServiceStatus},
|
|
utils::i18n::t,
|
|
};
|
|
|
|
async fn execute_service_operation_sync(status: ServiceStatus, op_type: &str) -> CmdResult {
|
|
if let Err(e) = SERVICE_MANAGER
|
|
.lock()
|
|
.await
|
|
.handle_service_status(&status)
|
|
.await
|
|
{
|
|
let emsg = format!("{} Service failed: {}", op_type, e);
|
|
return Err(t(emsg.as_str()).await);
|
|
}
|
|
Ok(())
|
|
}
|
|
|
|
#[tauri::command]
|
|
pub async fn install_service() -> CmdResult {
|
|
execute_service_operation_sync(ServiceStatus::InstallRequired, "Install").await
|
|
}
|
|
|
|
#[tauri::command]
|
|
pub async fn uninstall_service() -> CmdResult {
|
|
execute_service_operation_sync(ServiceStatus::UninstallRequired, "Uninstall").await
|
|
}
|
|
|
|
#[tauri::command]
|
|
pub async fn reinstall_service() -> CmdResult {
|
|
execute_service_operation_sync(ServiceStatus::ReinstallRequired, "Reinstall").await
|
|
}
|
|
|
|
#[tauri::command]
|
|
pub async fn repair_service() -> CmdResult {
|
|
execute_service_operation_sync(ServiceStatus::ForceReinstallRequired, "Repair").await
|
|
}
|
|
|
|
#[tauri::command]
|
|
pub async fn is_service_available() -> CmdResult<bool> {
|
|
service::is_service_available()
|
|
.await
|
|
.map(|_| true)
|
|
.map_err(|e| e.to_string())
|
|
}
|