feat: 实现后端多环境配置机制
- 使用 toml crate 替代 config crate 直接读取配置文件 - 创建 config/default.toml、config/development.toml、config/production.toml - 重写 config.rs 支持多环境配置加载 - 增强 deploy.sh 支持 development/production 环境参数 - 更新 IMPROVEMENTS.md 标记环境区分完成
This commit is contained in:
@@ -149,7 +149,11 @@ pub struct WeatherData {
|
||||
#[sqlx(rename = "averagewindspeed")]
|
||||
pub average_wind_speed: f64,
|
||||
|
||||
#[serde(rename = "calculatedWindSpeed", alias = "calculated_wind_speed", alias = "calculatedwindspeed")]
|
||||
#[serde(
|
||||
rename = "calculatedWindSpeed",
|
||||
alias = "calculated_wind_speed",
|
||||
alias = "calculatedwindspeed"
|
||||
)]
|
||||
#[sqlx(rename = "calculatedwindspeed")]
|
||||
pub calculated_wind_speed: Option<f64>, // 这个已经是 Option,很好
|
||||
|
||||
@@ -305,6 +309,7 @@ pub struct AppState {
|
||||
pub jwt_secret: String,
|
||||
pub wechat_appid: String,
|
||||
pub wechat_secret: String,
|
||||
pub free_user_data_limit: i32,
|
||||
}
|
||||
|
||||
impl AppState {
|
||||
@@ -316,6 +321,9 @@ impl AppState {
|
||||
.map_err(|_| "环境变量WECHAT_APPID未设置".to_string())?,
|
||||
wechat_secret: std::env::var("WECHAT_SECRET")
|
||||
.map_err(|_| "环境变量WECHAT_SECRET未设置".to_string())?,
|
||||
free_user_data_limit: std::env::var("FREE_USER_DATA_LIMIT")
|
||||
.map(|v| v.parse().unwrap_or(20))
|
||||
.unwrap_or(20),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user