From 9854a8ad62bb8ba402f93d6efe8c519629e7cfe2 Mon Sep 17 00:00:00 2001 From: matresnan <1358168412@qq.com> Date: Mon, 18 Aug 2025 16:25:55 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E8=B7=AF=E5=BE=84=E8=8E=B7=E5=8F=96=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E7=BB=9F=E4=B8=80=E4=BD=BF=E7=94=A8=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E7=9B=AE=E5=BD=95=E4=B8=8B=E7=9A=84=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 优化数据库路径获取逻辑,移除操作系统判断分支,统一使用当前目录下的数据库路径。 --- src/main.rs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3223181..c78ab93 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,21 +27,12 @@ pub struct Authorize { #[tokio::main] async fn main() -> Result<(), Box> { // 根据操作系统选择数据库路径 - let windows_path: String = env::current_dir() + let db_path: String = env::current_dir() .expect("无法获取当前目录") .join("authorize_data/database.db") .to_string_lossy() .into_owned(); - // 现在可以取切片 - let db_path: &str = if cfg!(target_os = "windows") { - &windows_path - } else if cfg!(target_os = "linux") { - "/usr/local/etc/authorize_data/database.db" - } else { - panic!("不支持的操作系统"); - }; - let db = Arc::new(db::Db::new(db_path).await?); let generator = Arc::new( generate::TokenGenerator::new()