* 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>
51 lines
1.4 KiB
Rust
51 lines
1.4 KiB
Rust
use std::sync::Arc;
|
|
use tauri::{AppHandle, Emitter, State};
|
|
|
|
use crate::commands::connection::AppState;
|
|
|
|
pub use dbx_core::table_export::{ExportStatus, TableExportProgress, TableExportRequest};
|
|
|
|
fn emit_progress(app: &AppHandle, progress: TableExportProgress) {
|
|
let _ = app.emit("table-export-progress", progress);
|
|
}
|
|
|
|
#[tauri::command]
|
|
pub async fn start_table_export(
|
|
app: AppHandle,
|
|
state: State<'_, Arc<AppState>>,
|
|
request: TableExportRequest,
|
|
) -> Result<(), String> {
|
|
let state = state.inner().clone();
|
|
let export_id = request.export_id.clone();
|
|
|
|
tokio::spawn(async move {
|
|
let result =
|
|
dbx_core::table_export::export_table_data_core(&state, &request, |progress| emit_progress(&app, progress))
|
|
.await;
|
|
|
|
if let Err(e) = result {
|
|
emit_progress(
|
|
&app,
|
|
TableExportProgress {
|
|
export_id: export_id.clone(),
|
|
table_name: String::new(),
|
|
rows_exported: 0,
|
|
total_rows: None,
|
|
status: ExportStatus::Error,
|
|
error_message: Some(e),
|
|
},
|
|
);
|
|
}
|
|
|
|
dbx_core::database_export::clear_export_cancelled(&export_id).await;
|
|
});
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[tauri::command]
|
|
pub async fn cancel_table_export(export_id: String) -> Result<(), String> {
|
|
dbx_core::database_export::set_export_cancelled(&export_id).await;
|
|
Ok(())
|
|
}
|