feat(feed_detail): add loadAllComments parameter to GetFeedDetail functionality

- Enhanced GetFeedDetail method to support loading all comments based on the new loadAllComments parameter.
- Updated related handlers and request structures to accommodate the new parameter.
- Improved logging to reflect the loading of all comments during feed detail retrieval.
- Implemented JavaScript logic to scroll and collect comments when loadAllComments is true.
This commit is contained in:
chekayo
2025-11-01 20:55:51 +08:00
parent a169db603b
commit 6484e58ade
6 changed files with 286 additions and 15 deletions

View File

@@ -4,10 +4,12 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/sirupsen/logrus"
"github.com/xpzouying/xiaohongshu-mcp/xiaohongshu"
"strconv"
"strings"
"time"
"github.com/sirupsen/logrus"
"github.com/xpzouying/xiaohongshu-mcp/xiaohongshu"
)
// MCP 工具处理函数
@@ -306,9 +308,23 @@ func (s *AppServer) handleGetFeedDetail(ctx context.Context, args map[string]any
}
}
logrus.Infof("MCP: 获取Feed详情 - Feed ID: %s", feedID)
loadAll := false
if raw, ok := args["load_all_comments"]; ok {
switch v := raw.(type) {
case bool:
loadAll = v
case string:
if parsed, err := strconv.ParseBool(v); err == nil {
loadAll = parsed
}
case float64:
loadAll = v != 0
}
}
result, err := s.xiaohongshuService.GetFeedDetail(ctx, feedID, xsecToken)
logrus.Infof("MCP: 获取Feed详情 - Feed ID: %s, loadAllComments=%v", feedID, loadAll)
result, err := s.xiaohongshuService.GetFeedDetail(ctx, feedID, xsecToken, loadAll)
if err != nil {
return &MCPToolResult{
Content: []MCPContent{{