chore: 提交所有工作进度 — SaaS 后端增强、Admin UI、桌面端集成

包含大量 SaaS 平台改进、Admin 管理后台更新、桌面端集成完善、
文档同步、测试文件重构等内容。为 QA 测试准备干净工作树。
This commit is contained in:
iven
2026-03-29 10:46:26 +08:00
parent 9a5fad2b59
commit 5fdf96c3f5
268 changed files with 22011 additions and 3886 deletions

View File

@@ -1,6 +1,6 @@
//! 应用状态
use sqlx::SqlitePool;
use sqlx::PgPool;
use std::sync::Arc;
use std::time::Instant;
use tokio::sync::RwLock;
@@ -10,7 +10,7 @@ use crate::config::SaaSConfig;
#[derive(Clone)]
pub struct AppState {
/// 数据库连接池
pub db: SqlitePool,
pub db: PgPool,
/// 服务器配置 (可热更新)
pub config: Arc<RwLock<SaaSConfig>>,
/// JWT 密钥
@@ -20,7 +20,7 @@ pub struct AppState {
}
impl AppState {
pub fn new(db: SqlitePool, config: SaaSConfig) -> anyhow::Result<Self> {
pub fn new(db: PgPool, config: SaaSConfig) -> anyhow::Result<Self> {
let jwt_secret = config.jwt_secret()?;
Ok(Self {
db,
@@ -29,4 +29,13 @@ impl AppState {
rate_limit_entries: Arc::new(dashmap::DashMap::new()),
})
}
/// 清理过期的限流条目 (60 秒窗口外的记录)
pub fn cleanup_rate_limit_entries(&self) {
let window_start = Instant::now() - std::time::Duration::from_secs(60);
self.rate_limit_entries.retain(|_, entries| {
entries.retain(|&ts| ts > window_start);
!entries.is_empty()
});
}
}