feat: 知识库文档列表标题增加「清空」按钮——一键清空全部文档(分块与检索索引级联删除),清空前弹窗警告确认

This commit is contained in:
xianrenge
2026-08-18 01:37:29 +08:00
parent 405bdec2c6
commit 01b17177c8
7 changed files with 82 additions and 4 deletions
+10
View File
@@ -1668,6 +1668,16 @@ pub fn remove_kb_document(state: State<'_, App>, document_id: String) -> Result<
kb_db::delete_document(&db, &document_id).map_err(|e| e.to_string())
}
/// 清空知识库内的全部文档(分块与检索索引一并删除)。
#[tauri::command]
pub fn kb_clear_documents(state: State<'_, App>, kb_id: String) -> Result<i64, String> {
let db = state.core.db.lock().unwrap();
kb_db::get_knowledge_base(&db, &kb_id)
.map_err(|e| e.to_string())?
.ok_or_else(|| "知识库不存在".to_string())?;
kb_db::delete_all_documents(&db, &kb_id).map_err(|e| e.to_string())
}
/// 按知识库最新分块设置重新切分指定文档。
#[tauri::command]
pub fn kb_rechunk_document(
+1
View File
@@ -194,6 +194,7 @@ pub fn run() {
commands::get_kb_document,
commands::kb_import_documents,
commands::remove_kb_document,
commands::kb_clear_documents,
commands::kb_rechunk_document,
commands::kb_search,
commands::kb_list_sources,