For AI agents: the complete documentation index is available at https://docs.halo.run/llms.txt, the full documentation bundle is available at https://docs.halo.run/llms-full.txt, and this page is available as Markdown at https://docs.halo.run/developer-guide/plugin/extension-points/ui/plugin-list-item-operation-create.md.

插件数据列表操作菜单

此扩展点用于扩展插件数据列表的操作菜单项。

插件数据列表操作菜单

定义方式

export default definePlugin({
  extensionPoints: {
    "plugin:list-item:operation:create": (
      plugin: Ref<Plugin>,
    ): OperationItem<Plugin>[] => {
      return [
        {
          priority: 10,
          component: markRaw(VDropdownItem),
          props: {},
          action: (item?: Plugin) => {
            // do something
          },
          label: "foo",
          hidden: false,
          permissions: [],
          children: [],
        },
      ];
    },
  },
});

OperationItem<T>@halo-dev/ui-shared 提供,请直接使用当前依赖中的类型。priority 和使用 markRaw 包装的 component 为必需字段;propsactionlabelhiddenpermissions 和递归的 children 为可选字段。

priority 越小,操作项的显示位置越靠前(内置操作项通常以 0、10、20… 依次排列,如需插入到内置项之间,可选择中间值)。

实现案例

类型定义

Plugin

Plugin@halo-dev/api-client 提供,请直接使用当前依赖中的生成类型,不要根据本页重新定义:

  • metadata:插件名称、标签和注解等资源元数据。
  • spec:版本、Halo 版本范围、作者、依赖和配置引用等期望状态;除 version 外多数属性可能为空。
  • status?:插件运行阶段、条件、加载位置和 UI 资源等观测状态,尚未计算时可能为空。