feat: Try support service mode for MacOS

This commit is contained in:
MystiPanda
2024-03-31 21:44:34 +08:00
parent 9fc819a410
commit e95808e6be
11 changed files with 158 additions and 177 deletions

View File

@@ -92,17 +92,16 @@ pub fn clash_pid_path() -> Result<PathBuf> {
Ok(app_home_dir()?.join("clash.pid"))
}
#[cfg(target_os = "linux")]
#[cfg(not(target_os = "windows"))]
pub fn service_path() -> Result<PathBuf> {
Ok(app_resources_dir()?.join("clash-verge-service"))
}
}
#[cfg(windows)]
pub fn service_path() -> Result<PathBuf> {
Ok(app_resources_dir()?.join("clash-verge-service.exe"))
}
#[cfg(any(windows, target_os = "linux"))]
pub fn service_log_file() -> Result<PathBuf> {
use chrono::Local;

View File

@@ -135,13 +135,12 @@ pub fn delete_log() -> Result<()> {
for file in fs::read_dir(&log_dir)?.flatten() {
let _ = process_file(file);
}
#[cfg(target_os = "windows")]
{
let service_log_dir = log_dir.join("service");
for file in fs::read_dir(&service_log_dir)?.flatten() {
let _ = process_file(file);
}
let service_log_dir = log_dir.join("service");
for file in fs::read_dir(&service_log_dir)?.flatten() {
let _ = process_file(file);
}
Ok(())
}

View File

@@ -1,7 +1,6 @@
use std::process::Command;
#[cfg(target_os = "linux")]
pub fn linux_elevator() -> &'static str {
use std::process::Command;
match Command::new("which").arg("pkexec").output() {
Ok(output) => {
if output.stdout.is_empty() {