xhs_get_comments → xhs_get_sub_comments:针对单条评论加载子评论

getFeedDetail 已返回首屏一级评论(含 1-2 条子评论预览),不再需要独立的
评论加载工具。新增 xhs_get_sub_comments 针对指定一级评论加载完整子评论,
支持 max_count 参数(默认 20)控制加载量,避免超时和上下文溢出。

后端:
- schemas: GetFeedCommentsSchema → GetSubCommentsSchema (feed_id, xsec_token, comment_id, max_count)
- types: 删除 CommentsResult
- feed-detail: 删除 getFeedComments/scrapeComments/CommentSort/parseCommentElement,
  新增 getSubComments(导航→store就绪→定位评论→点击展开→读store)
- selectors: 删除 commentSort* 选择器
- index/routes: 注册新工具和路由,超时改用 feed_detail(60s)

前端:
- types/endpoints: 删除 CommentsResult,新增 getSubComments API
- FeedDetail: 删除独立评论加载逻辑,评论随详情显示,新增 handleLoadSubComments
- CommentTree: "还有 X 条回复" 改为可点击按钮,带加载状态
This commit is contained in:
2026-03-02 17:52:35 +08:00
parent a0f3a3cbac
commit 54a3d9708a
10 changed files with 273 additions and 375 deletions
+5 -5
View File
@@ -4,7 +4,7 @@ import type {
QRCodeResult,
Feed,
FeedDetail,
CommentsResult,
Comment,
UserProfile,
SearchFilters,
HealthResponse,
@@ -47,15 +47,15 @@ export const getFeedDetail = (feedId: string, xsecToken: string) =>
body: JSON.stringify({ feed_id: feedId, xsec_token: xsecToken }),
});
export const getFeedComments = (
export const getSubComments = (
feedId: string,
xsecToken: string,
sort: 'default' | 'newest' | 'most_liked' = 'default',
commentId: string,
maxCount = 20,
) =>
apiFetch<ApiResponse<CommentsResult>>('/api/xhs/feeds/comments', {
apiFetch<ApiResponse<Comment[]>>('/api/xhs/feeds/sub-comments', {
method: 'POST',
body: JSON.stringify({ feed_id: feedId, xsec_token: xsecToken, sort, max_count: maxCount }),
body: JSON.stringify({ feed_id: feedId, xsec_token: xsecToken, comment_id: commentId, max_count: maxCount }),
});
// User
-6
View File
@@ -64,12 +64,6 @@ export interface Comment {
subComments: Comment[];
}
export interface CommentsResult {
comments: Comment[];
hasMore: boolean;
totalCount: number;
}
export interface UserProfile {
id: string;
nickname: string;