From 9974bfbf58edbd8cfd6a279f3a0485275c50bcaf Mon Sep 17 00:00:00 2001 From: Milky0217 Date: Sun, 19 Apr 2026 20:50:56 +0800 Subject: [PATCH] =?UTF-8?q?fix(config):=20=E7=A7=BB=E9=99=A4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=B8=AD=E7=9A=84=20app=5Fversion=20=E5=BC=95?= =?UTF-8?q?=E7=94=A8=EF=BC=8C=E5=AE=8C=E6=88=90=E7=89=88=E6=9C=AC=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E7=BB=9F=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - config.rs: 移除 AppConfig.app_version 字段和日志输出 - main.rs: 移除 APP_VERSION 环境变量设置 - models.rs: 移除 AppState.app_version 字段 版本号现统一使用 Cargo.toml 中的 env!("CARGO_PKG_VERSION") --- src/config.rs | 7 +------ src/main.rs | 1 - src/models.rs | 3 --- 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/src/config.rs b/src/config.rs index e6c2dce..901c0d4 100644 --- a/src/config.rs +++ b/src/config.rs @@ -14,7 +14,6 @@ pub struct AppConfig { pub ssl_key_path: String, pub ssl_cert_path: String, pub rust_log: String, - pub app_version: String, pub environment: String, pub free_user_data_limit: i32, pub server_host: String, @@ -82,11 +81,7 @@ impl AppConfig { let app_config: AppConfig = toml::from_str(&settings.to_string()) .map_err(|e| format!("配置反序列化失败: {}", e))?; - tracing::info!( - "配置加载成功,环境={},app_version={}", - app_config.environment, - app_config.app_version - ); + tracing::info!("配置加载成功,环境={}", app_config.environment); Ok(app_config) } diff --git a/src/main.rs b/src/main.rs index 7196127..1c38d5c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -112,7 +112,6 @@ async fn main() -> std::io::Result<()> { std::env::set_var("SSL_CERT_PATH", &app_config.ssl_cert_path); std::env::set_var("RUST_LOG", &app_config.rust_log); std::env::set_var("FREE_USER_DATA_LIMIT", app_config.free_user_data_limit.to_string()); - std::env::set_var("APP_VERSION", &app_config.app_version); } // 初始化文件日志(JSON 格式,带轮转) diff --git a/src/models.rs b/src/models.rs index a6b6920..bc01c88 100644 --- a/src/models.rs +++ b/src/models.rs @@ -337,7 +337,6 @@ pub struct AppState { pub wechat_appid: String, pub wechat_secret: String, pub free_user_data_limit: i32, - pub app_version: String, } impl AppState { @@ -352,8 +351,6 @@ impl AppState { free_user_data_limit: std::env::var("FREE_USER_DATA_LIMIT") .map(|v| v.parse().unwrap_or(20)) .unwrap_or(20), - app_version: std::env::var("APP_VERSION") - .unwrap_or_else(|_| "unknown".to_string()), }) } }