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/reply-list-item-field-create.md.

回复数据列表显示字段

此扩展点在 Halo 2.28.0 中引入,用于扩展回复数据列表的显示字段。

插件返回的字段会按 position 分别显示在列表项的 start(左侧)或 end(右侧)区域,并渲染在该区域内置内容之前。同一区域内的字段按 priority 升序排列;hidden 为 true,或当前用户不具备 permissions 中声明的任一权限时,字段不会渲染。

扩展点接收当前回复的 ListedReply 响应式引用。列表数据更新时,字段会使用最新的回复数据重新渲染。

定义方式

export default definePlugin({
  extensionPoints: {
    "reply:list-item:field:create": (
      reply: Ref<ListedReply>,
    ): EntityFieldItem[] => {
      return [
        {
          priority: 0,
          position: "start",
          component: markRaw(FooComponent),
          props: {},
          permissions: [],
          hidden: false,
        },
      ];
    },
  },
});
EntityFieldItem
export interface EntityFieldItem {
  priority: number;
  position: "start" | "end";
  component: Raw<Component>;
  props?: Record\<string, unknown\>;
  permissions?: string[];
  hidden?: boolean;
}

示例

此示例将在回复列表右侧显示回复所属评论的资源名称。

import type { ListedReply } from "@halo-dev/api-client";
import { VEntityField } from "@halo-dev/components";
import { definePlugin } from "@halo-dev/ui-shared";
import { markRaw, type Ref } from "vue";

export default definePlugin({
  extensionPoints: {
    "reply:list-item:field:create": (reply: Ref<ListedReply>) => {
      return [
        {
          priority: 0,
          position: "end",
          component: markRaw(VEntityField),
          props: {
            description: reply.value.reply.spec.commentName,
          },
          permissions: [],
          hidden: false,
        },
      ];
    },
  },
});

类型定义

ListedReply

ListedReply 由 @halo-dev/api-client 提供,请直接使用当前依赖中的生成类型。它包含:

  • reply:回复资源。
  • owner:解析后的回复者信息。
  • stats:回复的统计数据。