fix: 收口批次D并修复本地垃圾箱清空

This commit is contained in:
lix-2026
2026-05-21 15:45:11 +08:00
parent e709c0705c
commit dc18ec0a60
14 changed files with 525 additions and 72 deletions
+19 -16
View File
@@ -953,13 +953,12 @@ fn render_local_trash_workbench_html(
let original = escape_html(&entry.original_relative_path);
let trash_path = escape_html(&entry.trash_relative_path);
let kind = escape_html(&entry.resource_kind);
let filetree_row_id = if entry.resource_kind == "markdown"
|| entry.resource_kind == "markdown_bundle"
{
format!("doc:{}", entry.document_id)
} else {
format!("local:asset:{}", entry.original_relative_path)
};
let filetree_row_id =
if entry.resource_kind == "markdown" || entry.resource_kind == "markdown_bundle" {
format!("doc:{}", entry.document_id)
} else {
format!("local:asset:{}", entry.original_relative_path)
};
let row = format!(
r#"<article class="mnote-trash-row" data-trash-row="local" data-trash-entry-id="{entry_id}" data-resource-kind="{kind}" data-filetree-row-id="{filetree_row_id}">
<div class="mnote-trash-row-main">
@@ -1105,16 +1104,18 @@ fn render_local_trash_workbench_html(
if (rows.length === 0) return;
if (!window.confirm('清空后无法恢复,确定继续吗?')) return;
button.disabled = true;
Promise.all(rows.map(function(row) {{
var entryId = row.getAttribute('data-trash-entry-id') || '';
return postJson('/api/tree/commands', {{
action: 'purge',
sourceKind: 'local_folder',
rootUri: rootUri,
workspaceId: workspaceId,
documentId: entryId
rows.reduce(function(chain, row) {{
return chain.then(function() {{
var entryId = row.getAttribute('data-trash-entry-id') || '';
return postJson('/api/tree/commands', {{
action: 'purge',
sourceKind: 'local_folder',
rootUri: rootUri,
workspaceId: workspaceId,
documentId: entryId
}});
}});
}})).then(function() {{
}}, Promise.resolve()).then(function() {{
return refresh();
}}).then(function() {{
setStatus(action === 'local-empty-documents' ? '已清空页面垃圾箱' : '已清空资源垃圾箱', false);
@@ -2254,6 +2255,8 @@ mod tests {
assert!(html.contains("mnote.pendingLocalFolderRestoreFiletreeRowId"));
assert!(html.contains(r#"data-trash-action="local-empty-documents""#));
assert!(html.contains(r#"data-trash-action="local-empty-resources" disabled"#));
assert!(html.contains("rows.reduce(function(chain, row)"));
assert!(!html.contains("Promise.all(rows.map(function(row)"));
let _ = std::fs::remove_dir_all(&root);
}