评论
三种内容类型(视频、游戏、图片)各有独立的评论接口,结构相同,仅路由名和关联 ID 字段不同。
| 内容类型 | 路由前缀 | 关联字段 |
|---|---|---|
| 视频 | comment | videoId |
| 游戏 | gameComment | gameId |
| 图片 | imagePostComment | imagePostId |
以下以视频评论
comment.*为例,游戏和图片接口结构一致。
获取评论列表
POST
/api/trpc/comment.list公开| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
videoId | string | 是 | 视频 ID(游戏用 gameId,图片用 imagePostId) |
sort | string | 否 | 排序:newest / oldest / popular |
cursor | string | 否 | 分页游标 |
limit | number | 否 | 每页数量 |
获取回复
POST
/api/trpc/comment.getReplies公开| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
commentId | string | 是 | 父评论 ID |
cursor | string | 否 | 分页游标 |
limit | number | 否 | 每页数量 |
获取评论数
POST
/api/trpc/comment.getCount公开| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
videoId | string | 是 | 内容 ID |
发表评论
POST
/api/trpc/comment.create公开comment:write部分站点配置需要登录才能评论,未登录时可能返回
UNAUTHORIZED。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
videoId | string | 是 | 内容 ID |
content | string | 是 | 评论内容 |
parentId | string | 否 | 父评论 ID(用于回复) |
replyToUserId | string | 否 | 回复的用户 ID |
编辑评论
POST
/api/trpc/comment.update需登录comment:write| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | string | 是 | 评论 ID |
content | string | 是 | 新内容 |
删除评论
POST
/api/trpc/comment.delete需登录comment:write| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | string | 是 | 评论 ID |
评论互动
POST
/api/trpc/comment.react需登录comment:write| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
commentId | string | 是 | 评论 ID |
isLike | boolean | null | 是 | true 点赞 / false 点踩 / null 取消 |
置顶评论
POST
/api/trpc/comment.pin需登录comment:write仅内容上传者或管理员可操作。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
commentId | string | 是 | 评论 ID |
isPinned | boolean | 是 | 是否置顶 |
最近评论
POST
/api/trpc/comment.listRecent公开全站最近评论,按时间倒序。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
page | number | 是 | 页码 |
limit | number | 是 | 每页数量 |