Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(docs): move blocking html export and annotation save off async runtime

Jinpy9b364bbbc777
diff --git a/src-tauri/src/commands/docs.rs b/src-tauri/src/commands/docs.rs
index a0845f7d90..fd67d5cf87 100644
--- a/src-tauri/src/commands/docs.rs
+++ b/src-tauri/src/commands/docs.rs
@@ -121,7 +121,10 @@ pub async fn docs_save_annotations(
annotations: AnnotationFile,
) -> Result<(), String> {
let path = notes_path_of(&state, &connection_id).await?;
- save_annotations(&path, &annotations)
+ // 注释文件写入是同步磁盘 IO:放到阻塞线程池,避免占用 tokio worker
+ tauri::async_runtime::spawn_blocking(move || save_annotations(&path, &annotations))
+ .await
+ .map_err(|error| format!("annotation save task failed: {error}"))?
}
#[tauri::command]
@@ -131,6 +134,13 @@ pub async fn docs_export_html(
annotations: AnnotationFile,
lang: String,
) -> Result<(), String> {
- let html = to_standalone_html(&snapshot, &annotations, &lang)?;
- std::fs::write(&file_path, html).map_err(|error| format!("Failed to write {file_path}: {error}"))
+ // standalone HTML 可能达数 MB,序列化加写盘都是阻塞工作:与
+ // csv_export/xlsx_export 一致走 spawn_blocking,避免占用共享 runtime
+ // 的 tokio worker。
+ tauri::async_runtime::spawn_blocking(move || -> Result<(), String> {
+ let html = to_standalone_html(&snapshot, &annotations, &lang)?;
+ std::fs::write(&file_path, html).map_err(|error| format!("Failed to write {file_path}: {error}"))
+ })
+ .await
+ .map_err(|error| format!("docs export task failed: {error}"))?
}