返回 AiToEarn
types.ts
根目录 / project / aitoearn-web / src / store / plugin / plats / xhs / types.ts
1 /**
2 * 小红书平台特定类型定义
3 */
4
5 // ============================================================================
6 // 首页列表相关类型
7 // ============================================================================
8
9 /**
10 * 小红书首页列表响应类型
11 */
12 export interface XhsHomeFeedResponse {
13 success: boolean
14 code: number
15 msg?: string
16 data?: {
17 items: XhsHomeFeedItem[]
18 cursor_score: string
19 }
20 }
21
22 /**
23 * 小红书首页列表项原始类型
24 */
25 export interface XhsHomeFeedItem {
26 id: string
27 model_type: string
28 xsec_token: string
29 note_card: {
30 type: 'video' | 'normal'
31 display_title: string
32 cover: {
33 url_default: string
34 url_pre: string
35 width: number
36 height: number
37 }
38 user: {
39 user_id: string
40 nickname: string
41 nick_name: string
42 avatar: string
43 xsec_token: string
44 }
45 interact_info: {
46 /** 是否已点赞 */
47 liked: boolean
48 /** 点赞数 */
49 liked_count: string
50 /** 是否已收藏 */
51 collected?: boolean
52 /** 是否已关注 */
53 followed?: boolean
54 }
55 /** 话题标签列表 */
56 tag_list?: Array<{
57 id: string
58 name: string
59 type: string
60 }>
61 video?: {
62 capa?: {
63 duration: number
64 }
65 }
66 }
67 }
68
69 // ============================================================================
70 // 通用响应类型
71 // ============================================================================
72
73 /**
74 * 小红书通用 API 响应
75 */
76 export interface XhsBaseResponse {
77 success: boolean
78 code: number
79 msg?: string
80 }
81
82 /**
83 * 小红书评论响应(发布评论)
84 */
85 export interface XhsCommentResponse extends XhsBaseResponse {
86 data?: {
87 comment: {
88 id: string
89 [key: string]: unknown
90 }
91 }
92 }
93
94 // ============================================================================
95 // 评论列表相关类型
96 // ============================================================================
97
98 /**
99 * 小红书评论用户信息
100 */
101 export interface XhsCommentUserInfo {
102 /** 用户ID */
103 user_id: string
104 /** 用户昵称 */
105 nickname: string
106 /** 用户头像 */
107 image: string
108 /** 安全token */
109 xsec_token: string
110 }
111
112 /**
113 * 小红书评论项(一级评论)
114 */
115 export interface XhsCommentItem {
116 /** 评论ID */
117 id: string
118 /** 笔记ID */
119 note_id: string
120 /** 评论内容 */
121 content: string
122 /** 创建时间(毫秒级时间戳) */
123 create_time: number
124 /** 点赞数(字符串) */
125 like_count: string
126 /** 用户信息 */
127 user_info: XhsCommentUserInfo
128 /** IP属地 */
129 ip_location?: string
130 /** 状态 */
131 status: number
132 /** @提到的用户列表 */
133 at_users: Array<{
134 user_id: string
135 nickname: string
136 }>
137 /** 是否已点赞 */
138 liked: boolean
139 /** 标签(如 is_author 表示作者) */
140 show_tags: string[]
141 /** 子评论数量(字符串) */
142 sub_comment_count: string
143 /** 子评论列表 */
144 sub_comments: XhsSubCommentItem[]
145 /** 子评论分页游标 */
146 sub_comment_cursor: string
147 /** 是否有更多子评论 */
148 sub_comment_has_more: boolean
149 }
150
151 /**
152 * 小红书子评论项(二级评论)
153 */
154 export interface XhsSubCommentItem {
155 /** 评论ID */
156 id: string
157 /** 笔记ID */
158 note_id: string
159 /** 评论内容 */
160 content: string
161 /** 创建时间(毫秒级时间戳) */
162 create_time: number
163 /** 点赞数(字符串) */
164 like_count: string
165 /** 用户信息 */
166 user_info: XhsCommentUserInfo
167 /** IP属地 */
168 ip_location?: string
169 /** 状态 */
170 status: number
171 /** @提到的用户列表 */
172 at_users: Array<{
173 user_id: string
174 nickname: string
175 }>
176 /** 是否已点赞 */
177 liked: boolean
178 /** 标签(如 is_author 表示作者) */
179 show_tags: string[]
180 /** 回复目标评论 */
181 target_comment?: {
182 id: string
183 user_info: XhsCommentUserInfo
184 }
185 }
186
187 /**
188 * 小红书评论列表响应
189 */
190 export interface XhsCommentListResponse extends XhsBaseResponse {
191 data?: {
192 /** 评论列表 */
193 comments: XhsCommentItem[]
194 /** 下一页游标 */
195 cursor: string
196 /** 是否有更多 */
197 has_more: boolean
198 /** 时间戳 */
199 time: number
200 /** 当前用户ID */
201 user_id: string
202 /** 安全token */
203 xsec_token: string
204 }
205 }
206
207 /**
208 * 小红书子评论列表响应
209 */
210 export interface XhsSubCommentListResponse extends XhsBaseResponse {
211 data?: {
212 /** 子评论列表 */
213 comments: XhsSubCommentItem[]
214 /** 下一页游标 */
215 cursor: string
216 /** 是否有更多 */
217 has_more: boolean
218 /** 时间戳 */
219 time: number
220 /** 当前用户ID */
221 user_id: string
222 /** 安全token */
223 xsec_token: string
224 }
225 }
226
226 lines TYPESCRIPT