From eef8dc3d43db44afc8e5a960f688ca7e88bdb233 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Fri, 18 Nov 2022 15:22:22 +0800 Subject: [PATCH] feat: add delete attachment group and policy support (#695) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /kind feature /milestone 2.0 #### What this PR does / why we need it: 支持删除附件分组和存储策略。 删除策略的逻辑为:删除前会根据策略查询附件,如果有附件,则无法删除,否则可以删除。 删除附件的逻辑为: 1. 选择`删除并将附件移动至未分组`时,会在前端批量调用更新附件的接口,将所有附件的 `groupRef` 置空。 2. 选择`删除并同时删除附件`时,会在前端批量调用删除附件接口。 #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/2706 #### Special notes for your reviewer: /cc @halo-dev/sig-halo-console 测试方式: 1. 需要执行 `pnpm build:packages` 2. 创建若干存储策略,并在部分存储策略中上传附件,再对存储策略做删除处理,需要满足以下情况: 1. 已包含附件的策略会提示不允许删除。 2. 未包含附件的策略可以删除 3. 创建若干分组,并在部分分组中上传附件,再对分组做删除处理,需要满足以下情况: 1. 选择`删除并将附件移动至未分组`时,检查分组是否被删除,且里面的附件是否已经被移动到未分组。 2. 选择`删除并同时删除附件`时,检查分组是否被删除,且里面的附件是否被删除。 #### Does this PR introduce a user-facing change? ```release-note 支持删除附件分组和存储策略。 ``` --- .../src/components/button/Button.vue | 2 +- .../contents/attachments/AttachmentList.vue | 1 + .../components/AttachmentGroupList.vue | 141 +++++++++++++++++- .../components/AttachmentPoliciesModal.vue | 118 ++++++++------- .../composables/use-attachment-group.ts | 19 ++- .../composables/use-attachment-policy.ts | 19 ++- 6 files changed, 243 insertions(+), 57 deletions(-) diff --git a/packages/components/src/components/button/Button.vue b/packages/components/src/components/button/Button.vue index db9937da..32dd9816 100644 --- a/packages/components/src/components/button/Button.vue +++ b/packages/components/src/components/button/Button.vue @@ -137,7 +137,7 @@ function handleClick() { } .btn-danger { - background: #d71d1d; + background-color: #d71d1d !important; @apply text-white; } diff --git a/src/modules/contents/attachments/AttachmentList.vue b/src/modules/contents/attachments/AttachmentList.vue index 339e3fbc..e5614fe8 100644 --- a/src/modules/contents/attachments/AttachmentList.vue +++ b/src/modules/contents/attachments/AttachmentList.vue @@ -540,6 +540,7 @@ onMounted(() => { v-model:selected-group="selectedGroup" @select="onGroupChange" @update="handleFetchGroups" + @reload-attachments="handleFetchAttachments" /> diff --git a/src/modules/contents/attachments/components/AttachmentGroupList.vue b/src/modules/contents/attachments/components/AttachmentGroupList.vue index 7b98b332..b7957ba9 100644 --- a/src/modules/contents/attachments/components/AttachmentGroupList.vue +++ b/src/modules/contents/attachments/components/AttachmentGroupList.vue @@ -1,9 +1,17 @@