diff --git a/ui/console-src/modules/contents/comments/components/CommentListItem.vue b/ui/console-src/modules/contents/comments/components/CommentListItem.vue index 296902c5f..6927cacb1 100644 --- a/ui/console-src/modules/contents/comments/components/CommentListItem.vue +++ b/ui/console-src/modules/contents/comments/components/CommentListItem.vue @@ -29,12 +29,23 @@ import { import type { CommentSubjectRefProvider, CommentSubjectRefResult, + OperationItem, } from "@halo-dev/console-shared"; import { useMutation, useQuery, useQueryClient } from "@tanstack/vue-query"; -import { computed, onMounted, provide, ref, type Ref } from "vue"; +import { + computed, + onMounted, + provide, + ref, + type Ref, + toRefs, + markRaw, +} from "vue"; import { useI18n } from "vue-i18n"; import ReplyCreationModal from "./ReplyCreationModal.vue"; import ReplyListItem from "./ReplyListItem.vue"; +import { useOperationItemExtensionPoint } from "@console/composables/use-operation-extension-points"; +import EntityDropdownItems from "@/components/entity/EntityDropdownItems.vue"; const { currentUserHasPermission } = usePermission(); const { t } = useI18n(); @@ -50,6 +61,8 @@ const props = withDefaults( } ); +const { comment } = toRefs(props); + const hoveredReply = ref(); const showReplies = ref(false); const replyModal = ref(false); @@ -293,6 +306,35 @@ const subjectRefResult = computed(() => { } return subjectRef.resolve(subject); }); + +const { operationItems } = useOperationItemExtensionPoint( + "comment:list-item:operation:create", + comment, + computed((): OperationItem[] => [ + { + priority: 0, + component: markRaw(VDropdownItem), + label: t("core.comment.operations.approve_comment_in_batch.button"), + action: handleApprove, + hidden: props.comment?.comment.spec.approved, + }, + { + priority: 10, + component: markRaw(VDropdownItem), + label: t("core.comment.operations.approve_applies_in_batch.button"), + action: handleApproveReplyInBatch, + }, + { + priority: 20, + component: markRaw(VDropdownItem), + props: { + type: "danger", + }, + label: t("core.common.buttons.delete"), + action: handleDelete, + }, + ]) +); diff --git a/ui/docs/extension-points/entity-listitem-operation.md b/ui/docs/extension-points/entity-listitem-operation.md index 3458b6c5e..ae747002e 100644 --- a/ui/docs/extension-points/entity-listitem-operation.md +++ b/ui/docs/extension-points/entity-listitem-operation.md @@ -9,6 +9,8 @@ 目前支持扩展的数据列表: - 文章:`"post:list-item:operation:create"?: (post: Ref) => | OperationItem[] | Promise[]>` +- 评论:`"comment:list-item:operation:create"?: (comment: Ref) => | OperationItem[] | Promise[]>` +- 回复:`"reply:list-item:operation:create"?: (reply: Ref) => | OperationItem[] | Promise[]>` - 插件:`"plugin:list-item:operation:create"?: (plugin: Ref) => | OperationItem[] | Promise[]>` - 备份:`"backup:list-item:operation:create"?: (backup: Ref) => | OperationItem[] | Promise[]>` - 主题:`"theme:list-item:operation:create"?: (theme: Ref) => | OperationItem[] | Promise[]>` diff --git a/ui/packages/shared/src/types/plugin.ts b/ui/packages/shared/src/types/plugin.ts index 91ef9da21..afaae30a8 100644 --- a/ui/packages/shared/src/types/plugin.ts +++ b/ui/packages/shared/src/types/plugin.ts @@ -11,6 +11,8 @@ import type { ListedPost, Plugin, Theme, + ListedComment, + ListedReply, } from "@halo-dev/api-client"; import type { AnyExtension } from "@halo-dev/richtext-editor"; import type { Component, Ref } from "vue"; @@ -52,6 +54,14 @@ export interface ExtensionPoint { post: Ref ) => OperationItem[]; + "comment:list-item:operation:create"?: ( + comment: Ref + ) => OperationItem[]; + + "reply:list-item:operation:create"?: ( + reply: Ref + ) => OperationItem[]; + "plugin:list-item:operation:create"?: ( plugin: Ref ) => OperationItem[];