2022-02-27 20:34:25 +03:00
|
|
|
use std::env::temp_dir;
|
2021-12-14 11:07:15 +03:00
|
|
|
use std::path::{Path, PathBuf};
|
|
|
|
use tauri::{
|
|
|
|
api::path::{home_dir, resource_dir},
|
2022-02-13 13:45:03 +03:00
|
|
|
Env, PackageInfo,
|
2021-12-14 11:07:15 +03:00
|
|
|
};
|
|
|
|
|
2022-03-18 05:59:35 +03:00
|
|
|
#[cfg(not(feature = "verge-dev"))]
|
|
|
|
static APP_DIR: &str = "clash-verge";
|
|
|
|
#[cfg(feature = "verge-dev")]
|
|
|
|
static APP_DIR: &str = "clash-verge-dev";
|
|
|
|
|
|
|
|
static CLASH_CONFIG: &str = "config.yaml";
|
|
|
|
static VERGE_CONFIG: &str = "verge.yaml";
|
|
|
|
static PROFILE_YAML: &str = "profiles.yaml";
|
|
|
|
static PROFILE_TEMP: &str = "clash-verge-runtime.yaml";
|
|
|
|
|
2021-12-14 11:07:15 +03:00
|
|
|
/// get the verge app home dir
|
|
|
|
pub fn app_home_dir() -> PathBuf {
|
|
|
|
home_dir()
|
|
|
|
.unwrap()
|
|
|
|
.join(Path::new(".config"))
|
2022-03-18 05:59:35 +03:00
|
|
|
.join(Path::new(APP_DIR))
|
2021-12-14 11:07:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/// get the resources dir
|
|
|
|
pub fn app_resources_dir(package_info: &PackageInfo) -> PathBuf {
|
2022-02-13 13:45:03 +03:00
|
|
|
resource_dir(package_info, &Env::default())
|
|
|
|
.unwrap()
|
|
|
|
.join("resources")
|
2021-12-14 11:07:15 +03:00
|
|
|
}
|
2022-02-27 20:34:25 +03:00
|
|
|
|
|
|
|
/// profiles dir
|
|
|
|
pub fn app_profiles_dir() -> PathBuf {
|
|
|
|
app_home_dir().join("profiles")
|
|
|
|
}
|
|
|
|
|
|
|
|
/// logs dir
|
|
|
|
pub fn app_logs_dir() -> PathBuf {
|
|
|
|
app_home_dir().join("logs")
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn clash_path() -> PathBuf {
|
|
|
|
app_home_dir().join(CLASH_CONFIG)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn verge_path() -> PathBuf {
|
|
|
|
app_home_dir().join(VERGE_CONFIG)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn profiles_path() -> PathBuf {
|
|
|
|
app_home_dir().join(PROFILE_YAML)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn profiles_temp_path() -> PathBuf {
|
|
|
|
temp_dir().join(PROFILE_TEMP)
|
|
|
|
}
|