From 2fa8a84050610a183a6bc16320cebcc12165bc40 Mon Sep 17 00:00:00 2001 From: Takagi <1103069291@qq.com> Date: Thu, 22 Feb 2024 11:46:10 +0800 Subject: [PATCH] pref: optimize the ui in moment editing mode (#83) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /kind improvement #### What this PR does / why we need it: 优化编辑状态下的瞬间列表样式 #### How to test it? 测试瞬间整体功能未发生变化即可。 #### Does this PR introduce a user-facing change? ```release-note 优化编辑状态下的瞬间列表样式 ``` --- console/src/components/MomentItem.vue | 124 ++++++++++++--- console/src/components/MomentPreview.vue | 187 ++++++----------------- console/src/views/MomentsList.vue | 4 +- 3 files changed, 152 insertions(+), 163 deletions(-) diff --git a/console/src/components/MomentItem.vue b/console/src/components/MomentItem.vue index 8a654b4..457a881 100644 --- a/console/src/components/MomentItem.vue +++ b/console/src/components/MomentItem.vue @@ -5,6 +5,18 @@ import { ref } from "vue"; import MomentEdit from "./MomentEdit.vue"; import MomentPreview from "./MomentPreview.vue"; import type { Contributor } from "@halo-dev/api-client/index"; +import { + Dialog, + Toast, + VAvatar, + VDropdown, + VDropdownItem, + IconEyeOff, +} from "@halo-dev/components"; +import { formatDatetime, relativeTimeTo } from "@/utils/date"; +import LucideMoreHorizontal from "~icons/lucide/more-horizontal"; + +import apiClient from "@/utils/api-client"; const props = withDefaults( defineProps<{ @@ -38,8 +50,24 @@ const handlerUpdate = (moment: Moment) => { emit("update", moment); }; -const handlerRemove = (moment: Moment) => { - emit("remove", moment); +const deleteMoment = () => { + Dialog.warning({ + title: "确定要删除该瞬间吗?", + description: "该操作不可逆", + confirmType: "danger", + onConfirm: async () => { + try { + const { data } = await apiClient.delete( + `/apis/moment.halo.run/v1alpha1/moments/${props.moment.metadata.name}` + ); + + Toast.success("删除成功"); + emit("remove", data); + } catch (error) { + console.error("Failed to delete comment", error); + } + }, + }); }; const handlerCancel = () => { @@ -48,21 +76,81 @@ const handlerCancel = () => { diff --git a/console/src/components/MomentPreview.vue b/console/src/components/MomentPreview.vue index 5be3c3d..93479f2 100644 --- a/console/src/components/MomentPreview.vue +++ b/console/src/components/MomentPreview.vue @@ -1,29 +1,16 @@