* docs(getting-started): set brew upgrade to use official homebrew cask * fix(mysql): make admin show handling dialect aware * fix(data-compare): create missing target tables during sync * feat(sql): suggest join conditions from foreign keys * fix(sidebar): use filtered order for range selection * fix(tabs): close connection tabs on disconnect * fix(sqlserver): execute cte queries without wrapping * fix(opengauss): open table structure editor * perf(export): 优化导出ui体验和性能 * perf(export): 优化导出ui体验和性能 * fix(export): normalize status casing and fix web route issues - Add missing table export web routes (POST /export/table, SSE progress, cancel) - Fix tauri table export Promise to wait for terminal events - Change cancel to return Ok(()) so it doesn't get overwritten as Error - Unify ExportStatus to PascalCase across all frontend components - Fix http.ts table export POST body wrapping - Fix duplicate pub mod in dbx-web routes * fix(export): return export file for browser download in web mode Write table export output to temp dir, register a download endpoint, and trigger browser download from the frontend when export completes. * fix(export): avoid table export progress races --------- Co-authored-by: Francesco Lucarelli <francesco06lucarelli@gmail.com> Co-authored-by: t8y2 <1156263951@qq.com> Co-authored-by: dqn <someonegdeng@qq.com>
30 lines
943 B
Rust
30 lines
943 B
Rust
use dbx_core::connection::AppState;
|
|
use std::collections::{HashMap, HashSet};
|
|
use std::path::PathBuf;
|
|
use std::sync::Arc;
|
|
use tokio::sync::{broadcast, Mutex, RwLock};
|
|
use tokio_util::sync::CancellationToken;
|
|
|
|
pub struct LoginRateLimit {
|
|
pub fail_count: u32,
|
|
pub locked_until: Option<std::time::Instant>,
|
|
}
|
|
|
|
pub struct WebState {
|
|
pub app: Arc<AppState>,
|
|
pub data_dir: PathBuf,
|
|
pub password_hash: RwLock<Option<String>>,
|
|
pub sessions: RwLock<HashSet<String>>,
|
|
pub sse_channels: RwLock<HashMap<String, broadcast::Sender<String>>>,
|
|
pub sql_file_executions: RwLock<HashMap<String, CancellationToken>>,
|
|
pub login_rate_limit: Mutex<LoginRateLimit>,
|
|
/// Table export temp files: export_id -> (file_path, format)
|
|
pub export_files: RwLock<HashMap<String, (String, String)>>,
|
|
}
|
|
|
|
impl WebState {
|
|
pub async fn remove_sse_channel(&self, id: &str) {
|
|
self.sse_channels.write().await.remove(id);
|
|
}
|
|
}
|