From 26d55bf29f04d186ad5caaa02dd69442bb1b2d99 Mon Sep 17 00:00:00 2001 From: Tlntin <371043382@qq.com> Date: Wed, 7 Dec 2022 18:40:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DLinux=20config=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E6=97=A0=E6=B3=95=E5=8A=A8=E6=80=81=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=90=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-tauri/src/main.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 3a80e10..a97376c 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -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")]