修复Linux config路径无法动态获取用户名问题

This commit is contained in:
Tlntin
2022-12-07 18:40:27 +08:00
parent f641f1c2b3
commit 26d55bf29f

View File

@@ -197,8 +197,17 @@ fn main() -> wry::Result<()> {
.build()?;
// 自定义cookie文件夹仅用于Linux
// Custom Cookie folder, only for Linux
// #[cfg(target_os = "linux")]
// let config_path = format!("/home/{}/.config/{}", env!("USER"), package_name);
#[cfg(target_os = "linux")]
let config_path = format!("/home/{}/.config/{}", env!("USER"), package_name);
let user = std::env::var_os("USER");
#[cfg(target_os = "linux")]
let config_path = match user {
Some(v) => format!(
"/home/{}/.config/{}", v.into_string().unwrap(), package_name
),
None => panic!("can't found any user")
};
#[cfg(target_os = "linux")]
let data_path = std::path::PathBuf::from(&config_path);
#[cfg(target_os = "linux")]