From 7162b8da9289419fbde241050d677eff6bca79a1 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Fri, 30 May 2025 18:10:28 +0800 Subject: [PATCH] fix: correct attachment selection state after new upload (#7487) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /area ui /kind bug /milestone 2.21.x #### What this PR does / why we need it: Fix correct attachment selection state after new upload. #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/7472 #### Does this PR introduce a user-facing change? ```release-note 修复当有已选择附件时,上传新附件导致所选附件状态异常的问题。 ``` --- .../contents/attachments/AttachmentList.vue | 28 ++++++---- .../components/AttachmentListItem.vue | 10 ++-- .../CoreSelectorProvider.vue | 14 +++-- .../attachments/composables/use-attachment.ts | 52 ++++++++++++------- .../CoreSelectorProvider.vue | 31 +++++------ 5 files changed, 76 insertions(+), 59 deletions(-) diff --git a/ui/console-src/modules/contents/attachments/AttachmentList.vue b/ui/console-src/modules/contents/attachments/AttachmentList.vue index fda62a13f..6bdc92b04 100644 --- a/ui/console-src/modules/contents/attachments/AttachmentList.vue +++ b/ui/console-src/modules/contents/attachments/AttachmentList.vue @@ -99,7 +99,7 @@ function handleClearFilters() { const { attachments, selectedAttachment, - selectedAttachments, + selectedAttachmentNames, checkedAll, isLoading, isFetching, @@ -128,13 +128,13 @@ const { size: size, }); -provide>>("selectedAttachments", selectedAttachments); +provide>>("selectedAttachmentNames", selectedAttachmentNames); const handleMove = async (group: Group) => { try { - const promises = Array.from(selectedAttachments.value).map((attachment) => { + const promises = Array.from(selectedAttachmentNames.value).map((name) => { return coreApiClient.storage.attachment.patchAttachment({ - name: attachment.metadata.name, + name, jsonPatchInner: [ { op: "add", @@ -146,7 +146,7 @@ const handleMove = async (group: Group) => { }); await Promise.all(promises); - selectedAttachments.value.clear(); + selectedAttachmentNames.value.clear(); Toast.success(t("core.attachment.operations.move.toast_success")); } catch (e) { @@ -161,13 +161,13 @@ const handleClickItem = (attachment: Attachment) => { return; } - if (selectedAttachments.value.size > 0) { + if (selectedAttachmentNames.value.size > 0) { handleSelect(attachment); return; } selectedAttachment.value = attachment; - selectedAttachments.value.clear(); + selectedAttachmentNames.value.clear(); detailVisible.value = true; }; @@ -299,14 +299,14 @@ watch(
{{ $t("core.common.buttons.delete") }} - + {{ $t("core.attachment.operations.deselect_items.button") }} @@ -560,12 +560,18 @@ watch(