diff --git a/console/docs/extension-points/entity-listitem-operation.md b/console/docs/extension-points/entity-listitem-operation.md index 230af936a..894e6bf27 100644 --- a/console/docs/extension-points/entity-listitem-operation.md +++ b/console/docs/extension-points/entity-listitem-operation.md @@ -10,6 +10,7 @@ - 文章:`"post:list-item:operation:create"?: () => | EntityDropdownItem[] | Promise[]>` - 插件:`"plugin:list-item:operation:create"?: () => | EntityDropdownItem[] | Promise[]>` +- 备份:`"backup:list-item:operation:create"?: () => | EntityDropdownItem[] | Promise[]>` 示例: diff --git a/console/packages/shared/src/types/plugin.ts b/console/packages/shared/src/types/plugin.ts index 794519085..87b38ca2c 100644 --- a/console/packages/shared/src/types/plugin.ts +++ b/console/packages/shared/src/types/plugin.ts @@ -8,7 +8,7 @@ import type { CommentSubjectRefProvider } from "@/states/comment-subject-ref"; import type { BackupTab } from "@/states/backup"; import type { PluginInstallationTab } from "@/states/plugin-installation-tabs"; import type { EntityDropdownItem } from "@/states/entity"; -import type { ListedPost, Plugin } from "@halo-dev/api-client"; +import type { Backup, ListedPost, Plugin } from "@halo-dev/api-client"; export interface RouteRecordAppend { parentName: RouteRecordName; @@ -46,6 +46,10 @@ export interface ExtensionPoint { "plugin:list-item:operation:create"?: () => | EntityDropdownItem[] | Promise[]>; + + "backup:list-item:operation:create"?: () => + | EntityDropdownItem[] + | Promise[]>; } export interface PluginModule { diff --git a/console/src/modules/system/backup/components/BackupListItem.vue b/console/src/modules/system/backup/components/BackupListItem.vue index 9e62e8b76..a331a5c64 100644 --- a/console/src/modules/system/backup/components/BackupListItem.vue +++ b/console/src/modules/system/backup/components/BackupListItem.vue @@ -10,11 +10,13 @@ import { } from "@halo-dev/components"; import type { Backup } from "@halo-dev/api-client"; import { relativeTimeTo, formatDatetime } from "@/utils/date"; -import { computed } from "vue"; +import { computed, markRaw } from "vue"; import { apiClient } from "@/utils/api-client"; import { useQueryClient } from "@tanstack/vue-query"; import prettyBytes from "pretty-bytes"; import { useI18n } from "vue-i18n"; +import { useEntityDropdownItemExtensionPoint } from "@/composables/use-entity-extension-points"; +import EntityDropdownItems from "@/components/entity/EntityDropdownItems.vue"; const queryClient = useQueryClient(); const { t } = useI18n(); @@ -94,6 +96,30 @@ function handleDelete() { }, }); } + +const { dropdownItems } = useEntityDropdownItemExtensionPoint( + "backup:list-item:operation:create", + [ + { + priority: 10, + component: markRaw(VDropdownItem), + label: t("core.common.buttons.download"), + visible: props.backup.status?.phase === "SUCCEEDED", + permissions: [], + action: () => handleDownload(), + }, + { + priority: 20, + component: markRaw(VDropdownItem), + props: { + type: "danger", + }, + label: t("core.common.buttons.delete"), + visible: true, + action: () => handleDelete(), + }, + ] +);