mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-04 16:37:46 +08:00
- 删除 1666 行的 admin/system/shared/system.rs,按职责拆分到独立模块 - 新增 handlers/shared/email_templates.rs 和 system_config_values.rs 存放跨层共用的模板/配置工具函数 - 新增 admin/system/shared/email_templates.rs 存放 admin 专用的模板操作逻辑 - 新增 admin/shared/proxy_errors.rs 存放 build_proxy_error_response - 清理 public/system_modules_helpers 中不属于 public 层的导出 - 新增架构测试守护模块归属边界
41 lines
1.2 KiB
Rust
41 lines
1.2 KiB
Rust
pub(crate) fn module_available_from_env(env_key: &str, default_available: bool) -> bool {
|
|
match std::env::var(env_key) {
|
|
Ok(value) => matches!(
|
|
value.trim().to_ascii_lowercase().as_str(),
|
|
"true" | "1" | "yes"
|
|
),
|
|
Err(_) => default_available,
|
|
}
|
|
}
|
|
|
|
pub(crate) fn system_config_bool(value: Option<&serde_json::Value>, default: bool) -> bool {
|
|
match value {
|
|
Some(serde_json::Value::Bool(value)) => *value,
|
|
Some(serde_json::Value::Number(value)) => {
|
|
value.as_i64().map(|value| value != 0).unwrap_or(default)
|
|
}
|
|
Some(serde_json::Value::String(value)) => {
|
|
match value.trim().to_ascii_lowercase().as_str() {
|
|
"true" | "1" | "yes" | "on" => true,
|
|
"false" | "0" | "no" | "off" => false,
|
|
_ => default,
|
|
}
|
|
}
|
|
_ => default,
|
|
}
|
|
}
|
|
|
|
pub(crate) fn system_config_string(value: Option<&serde_json::Value>) -> Option<String> {
|
|
match value {
|
|
Some(serde_json::Value::String(value)) => {
|
|
let value = value.trim();
|
|
if value.is_empty() {
|
|
None
|
|
} else {
|
|
Some(value.to_string())
|
|
}
|
|
}
|
|
_ => None,
|
|
}
|
|
}
|