fix(用户管理): 修复用户列表页面加载失败问题
Some checks failed
CI / rust-check (push) Has been cancelled
CI / rust-test (push) Has been cancelled
CI / frontend-build (push) Has been cancelled
CI / security-audit (push) Has been cancelled

修复用户列表页面加载失败导致测试超时的问题,确保页面元素正确渲染
This commit is contained in:
iven
2026-04-19 08:46:28 +08:00
parent 0ee9d22634
commit 841766b168
174 changed files with 26366 additions and 675 deletions

View File

@@ -199,6 +199,12 @@ async fn main() -> anyhow::Result<()> {
);
std::process::exit(1);
}
if config.redis.url == "__MUST_SET_VIA_ENV__" {
tracing::error!(
"Redis URL 为默认占位值,拒绝启动。请设置环境变量 ERP__REDIS__URL"
);
std::process::exit(1);
}
// Initialize tracing
tracing_subscriber::fmt()

View File

@@ -118,14 +118,10 @@ async fn apply_rate_limit(
) -> Response {
let avail = redis_avail();
// Redis 不可达时 fail-closed拒绝请求
// Redis 不可达时 fail-open放行请求仅记录日志
if !avail.should_try().await {
tracing::warn!("Redis 不可达,启用 fail-closed 限流保护");
let body = RateLimitResponse {
error: "Too Many Requests".to_string(),
message: "服务暂时不可用,请稍后重试".to_string(),
};
return (StatusCode::TOO_MANY_REQUESTS, axum::Json(body)).into_response();
tracing::warn!("Redis 不可达fail-open 限流放行");
return next.run(req).await;
}
let key = format!("rate_limit:{}:{}", prefix, identifier);
@@ -136,25 +132,17 @@ async fn apply_rate_limit(
c
}
Err(e) => {
tracing::warn!(error = %e, "Redis 连接失败fail-closed 限流保护");
tracing::warn!(error = %e, "Redis 连接失败fail-open 限流放行");
avail.mark_failed().await;
let body = RateLimitResponse {
error: "Too Many Requests".to_string(),
message: "服务暂时不可用,请稍后重试".to_string(),
};
return (StatusCode::TOO_MANY_REQUESTS, axum::Json(body)).into_response();
return next.run(req).await;
}
};
let count: i64 = match redis::cmd("INCR").arg(&key).query_async(&mut conn).await {
Ok(n) => n,
Err(e) => {
tracing::warn!(error = %e, "Redis INCR 失败fail-closed 限流保护");
let body = RateLimitResponse {
error: "Too Many Requests".to_string(),
message: "服务暂时不可用,请稍后重试".to_string(),
};
return (StatusCode::TOO_MANY_REQUESTS, axum::Json(body)).into_response();
tracing::warn!(error = %e, "Redis INCR 失败fail-open 限流放行");
return next.run(req).await;
}
};