diff --git a/src-tauri/src/utils/dirs.rs b/src-tauri/src/utils/dirs.rs index 6240f2af..0c7e7b5b 100644 --- a/src-tauri/src/utils/dirs.rs +++ b/src-tauri/src/utils/dirs.rs @@ -115,22 +115,12 @@ pub fn app_res_dir() -> Result { } pub fn clash_pid_path() -> Result { - unsafe { - Ok(RESOURCE_DIR - .clone() - .ok_or(anyhow::anyhow!("failed to get the resource dir"))? - .join("clash.pid")) - } + Ok(app_home_dir()?.join("clash.pid")) } #[cfg(windows)] pub fn service_path() -> Result { - unsafe { - let res_dir = RESOURCE_DIR - .clone() - .ok_or(anyhow::anyhow!("failed to get the resource dir"))?; - Ok(res_dir.join("clash-verge-service.exe")) - } + Ok(app_home_dir()?.join("clash-verge-service.exe")) } #[cfg(windows)] diff --git a/src-tauri/src/utils/init.rs b/src-tauri/src/utils/init.rs index 551b1936..ed6aa33a 100644 --- a/src-tauri/src/utils/init.rs +++ b/src-tauri/src/utils/init.rs @@ -116,7 +116,10 @@ pub fn delete_log() -> Result<()> { if file_name.ends_with(".log") { let now = Local::now(); let created_time = parse_time_str(&file_name[0..file_name.len() - 4])?; - let file_time = Local.from_local_datetime(&created_time).single().ok_or(anyhow::anyhow!("invalid local datetime"))?; + let file_time = Local + .from_local_datetime(&created_time) + .single() + .ok_or(anyhow::anyhow!("invalid local datetime"))?; let duration = now.signed_duration_since(file_time); if duration.num_days() > day { @@ -197,7 +200,14 @@ pub fn init_resources(package_info: &PackageInfo) -> Result<()> { } #[cfg(target_os = "windows")] - let file_list = ["Country.mmdb", "geoip.dat", "geosite.dat"]; + let file_list = [ + "Country.mmdb", + "geoip.dat", + "geosite.dat", + "clash-verge-service.exe", + "install-service.exe", + "uninstall-service.exe", + ]; #[cfg(not(target_os = "windows"))] let file_list = ["Country.mmdb", "geoip.dat", "geosite.dat"];