| 1 | import { Pagination } from './types'; |
| 2 | import { HotTopic } from './types/hotTopic'; |
| 3 | import { Topic } from './types/topic'; |
| 4 | import { ViralTitle } from './types/viralTitles'; |
| 5 | import { hotHttp } from './request'; |
| 6 | import { |
| 7 | GetAiToolsRankingApiParams, |
| 8 | GetAiToolsRankingApiRes, |
| 9 | } from './types/platform.type'; |
| 10 | |
| 11 | export interface Platform { |
| 12 | id: string; |
| 13 | _id: string; |
| 14 | name: string; |
| 15 | icon: string; |
| 16 | type: string; |
| 17 | description: string; |
| 18 | status: number; |
| 19 | config: Record<string, any>; |
| 20 | sort: number; |
| 21 | createTime: string; |
| 22 | updateTime: string; |
| 23 | } |
| 24 | |
| 25 | export interface RankingItem { |
| 26 | id: string; |
| 27 | title: string; |
| 28 | author: { |
| 29 | name: string; |
| 30 | avatar: string; |
| 31 | followers: string; |
| 32 | }; |
| 33 | category: { |
| 34 | name: string; |
| 35 | subCategory: string; |
| 36 | }; |
| 37 | duration: string; |
| 38 | views: string; |
| 39 | likes: string; |
| 40 | comments: string; |
| 41 | engagement: string; |
| 42 | thumbnail: string; |
| 43 | createTime: string; |
| 44 | } |
| 45 | |
| 46 | export interface PlatformRanking { |
| 47 | _id: string; |
| 48 | id: string; |
| 49 | name: string; |
| 50 | platformId: string; |
| 51 | parentId: string; |
| 52 | platform: Platform; |
| 53 | type: 'daily' | 'weekly' | 'monthly'; |
| 54 | description: string; |
| 55 | icon: string; |
| 56 | status: number; |
| 57 | rules: string; |
| 58 | config: Record<string, any>; |
| 59 | sort: number; |
| 60 | updateFrequency: string; |
| 61 | lastUpdateTime: string; |
| 62 | createTime: string; |
| 63 | updateTime: string; |
| 64 | items?: RankingItem[]; |
| 65 | } |
| 66 | |
| 67 | export interface Author { |
| 68 | id: string; |
| 69 | name: string; |
| 70 | avatar: string; |
| 71 | url: string; |
| 72 | fansCount: number; |
| 73 | } |
| 74 | |
| 75 | export interface Stats { |
| 76 | watchCount: number; |
| 77 | viewCount: number; |
| 78 | likeCount: number; |
| 79 | commentCount: number; |
| 80 | shareCount: number; |
| 81 | collectCount: number; |
| 82 | } |
| 83 | |
| 84 | export interface RankingContent { |
| 85 | _id: string; |
| 86 | id: string; |
| 87 | platformId: string; |
| 88 | rankingId: string; |
| 89 | originalId: string; |
| 90 | title: string; |
| 91 | type: 'article' | 'video'; |
| 92 | category: string; |
| 93 | url: string; |
| 94 | cover: string; |
| 95 | description: string; |
| 96 | author: Author; |
| 97 | stats: Stats; |
| 98 | status: number; |
| 99 | shareCount: number; |
| 100 | collectCount: number; |
| 101 | publishTime: string; |
| 102 | sort: number; |
| 103 | rankingPosition: number; |
| 104 | platform: Platform; |
| 105 | ranking: PlatformRanking; |
| 106 | anaAdd: any; |
| 107 | } |
| 108 | |
| 109 | export interface PaginationMeta { |
| 110 | itemCount: number; |
| 111 | totalItems: number; |
| 112 | itemsPerPage: number; |
| 113 | totalPages: number; |
| 114 | currentPage: number; |
| 115 | } |
| 116 | |
| 117 | export interface RankingContentsResponse { |
| 118 | items: RankingContent[]; |
| 119 | meta: PaginationMeta; |
| 120 | } |
| 121 | |
| 122 | export interface RankingContentsResponse { |
| 123 | items: RankingContent[]; |
| 124 | meta: PaginationMeta; |
| 125 | } |
| 126 | |
| 127 | export const platformApi = { |
| 128 | // 获取平台列表 |
| 129 | getPlatformList() { |
| 130 | return hotHttp.get<Platform[]>('/hotinfo/platform'); |
| 131 | }, |
| 132 | |
| 133 | // 获取平台榜单列表 |
| 134 | getPlatformRanking(platformId: string) { |
| 135 | return hotHttp.get<PlatformRanking[]>( |
| 136 | `/ranking/platform?platformId=${platformId}`, |
| 137 | ); |
| 138 | }, |
| 139 | |
| 140 | // 获取榜单内容 |
| 141 | getRankingContents( |
| 142 | rankingId: string, |
| 143 | page = 1, |
| 144 | pageSize = 20, |
| 145 | category?: string, |
| 146 | date?: string, |
| 147 | ) { |
| 148 | let ctr = null; |
| 149 | if (category && category != '全部') { |
| 150 | ctr = category; |
| 151 | } |
| 152 | return hotHttp.get<RankingContentsResponse>( |
| 153 | `/ranking/${rankingId}/contents`, |
| 154 | { |
| 155 | params: { |
| 156 | page, |
| 157 | pageSize, |
| 158 | category: ctr, |
| 159 | date, |
| 160 | }, |
| 161 | isToken: false, |
| 162 | }, |
| 163 | ); |
| 164 | }, |
| 165 | |
| 166 | // 获取榜单分类 |
| 167 | getRankingLabel(rankingId: string) { |
| 168 | return hotHttp.get<string[]>(`/ranking/label/${rankingId}`, { |
| 169 | isToken: false, |
| 170 | }); |
| 171 | }, |
| 172 | |
| 173 | // 获取榜单日期 |
| 174 | getRankingDates(rankingId: string) { |
| 175 | return hotHttp.get<string[]>(`/ranking/hotinfo/${rankingId}/dates`, { |
| 176 | isToken: false, |
| 177 | }); |
| 178 | }, |
| 179 | |
| 180 | // 获取所有热点事件 |
| 181 | getAllHotTopics() { |
| 182 | return hotHttp.get< |
| 183 | { |
| 184 | platform: Platform; |
| 185 | hotTopic: HotTopic; |
| 186 | }[] |
| 187 | >(`/hot-topics/all`, { |
| 188 | isToken: false, |
| 189 | }); |
| 190 | }, |
| 191 | |
| 192 | // ---- 热门专题 ---- |
| 193 | |
| 194 | // 获取所有专题标签 |
| 195 | getTopics() { |
| 196 | return hotHttp.get<string[]>(`/topics/topics`, { |
| 197 | isToken: false, |
| 198 | }); |
| 199 | }, |
| 200 | |
| 201 | // 获取所有专题类型1 |
| 202 | getMsgType() { |
| 203 | return hotHttp.get<string[]>(`/topics/msgType`, { |
| 204 | isToken: false, |
| 205 | }); |
| 206 | }, |
| 207 | |
| 208 | // 获取所有专题分类 |
| 209 | getTopicLabels(msgType: string) { |
| 210 | return hotHttp.get<string[]>(`/topics/labels/${msgType}`, { |
| 211 | isToken: false, |
| 212 | }); |
| 213 | }, |
| 214 | |
| 215 | // 获取专题的时间类型 |
| 216 | getTopicTimeTypes(msgType: string) { |
| 217 | return hotHttp.get<string[]>(`/topics/timeType/${msgType}`, { |
| 218 | isToken: false, |
| 219 | }); |
| 220 | }, |
| 221 | |
| 222 | // 获取热门专题列表 |
| 223 | getAllTopics(params: { |
| 224 | msgType?: string; // 项目类型 |
| 225 | timeType?: string; // 时间分类 |
| 226 | type?: string; // 类型 |
| 227 | platformId?: string; // 平台ID |
| 228 | startTime?: string; // 发布时间开始 |
| 229 | endTime?: string; // 发布时间结束 |
| 230 | topic?: string; // 话题标签 |
| 231 | page?: number; |
| 232 | pageSize?: number; |
| 233 | }) { |
| 234 | return hotHttp.get<Pagination<Topic>>(`/topics`, { |
| 235 | isToken: false, |
| 236 | params, |
| 237 | }); |
| 238 | }, |
| 239 | |
| 240 | // ---- 爆款标题 ---- |
| 241 | // 获取有数据的平台列表 |
| 242 | findPlatformsWithData() { |
| 243 | return hotHttp.get<Platform[]>(`/viral-titles/platforms`, { |
| 244 | isToken: false, |
| 245 | }); |
| 246 | }, |
| 247 | |
| 248 | // 获取指定平台的分类列表 |
| 249 | findCategoriesByPlatform(platformId: string) { |
| 250 | return hotHttp.get<string[]>( |
| 251 | `/viral-titles/platforms/${platformId}/categories`, |
| 252 | { |
| 253 | isToken: false, |
| 254 | }, |
| 255 | ); |
| 256 | }, |
| 257 | |
| 258 | // 获取平台下所有分类的前五条数据 |
| 259 | findTopByPlatformAndCategories( |
| 260 | platformId: string, |
| 261 | timeType?: string, // 时间分类 |
| 262 | ) { |
| 263 | return hotHttp.get< |
| 264 | { |
| 265 | category: string; |
| 266 | titles: ViralTitle[]; |
| 267 | }[] |
| 268 | >(`/viral-titles/platforms/${platformId}/top-by-categories`, { |
| 269 | isToken: false, |
| 270 | params: { |
| 271 | timeType, |
| 272 | }, |
| 273 | }); |
| 274 | }, |
| 275 | |
| 276 | // 获取爆款标题平台下指定分类的数据列表(分页) |
| 277 | findByPlatformAndCategory( |
| 278 | platformId: string, |
| 279 | params: { |
| 280 | category?: string; |
| 281 | startTime?: Date; |
| 282 | endTime?: Date; |
| 283 | timeType?: string; |
| 284 | page?: number; |
| 285 | pageSize?: number; |
| 286 | }, |
| 287 | ) { |
| 288 | return hotHttp.get<Pagination<ViralTitle>>( |
| 289 | `/viral-titles/platforms/${platformId}`, |
| 290 | { |
| 291 | isToken: false, |
| 292 | params, |
| 293 | }, |
| 294 | ); |
| 295 | }, |
| 296 | |
| 297 | // 获取爆款标题的时间类型 |
| 298 | getViralTitleTimeTypes() { |
| 299 | return hotHttp.get<string[]>(`/viral-titles/timeType`, { |
| 300 | isToken: false, |
| 301 | }); |
| 302 | }, |
| 303 | |
| 304 | // ---- 话题 ---- |
| 305 | // 获取有数据的平台列表 |
| 306 | findTalksPlatforms() { |
| 307 | return hotHttp.get<Platform[]>(`/talks/platforms`, { |
| 308 | isToken: false, |
| 309 | }); |
| 310 | }, |
| 311 | |
| 312 | // 获取话题栏目 |
| 313 | findTalksColumn(platformId: string) { |
| 314 | return hotHttp.get<string[]>(`/talks/column`, { |
| 315 | params: { |
| 316 | platformId, |
| 317 | }, |
| 318 | isToken: false, |
| 319 | }); |
| 320 | }, |
| 321 | |
| 322 | // 获取小红书话题流量榜、流量扶持日期 |
| 323 | getXhsDates() { |
| 324 | return hotHttp.get<string[]>(`/xhs/dates`, { |
| 325 | isToken: false, |
| 326 | }); |
| 327 | }, |
| 328 | |
| 329 | // 获取小红书话题流量榜、流量扶持分类 |
| 330 | getXhsCategories() { |
| 331 | return hotHttp.get<string[]>(`/xhs/category`, { |
| 332 | isToken: false, |
| 333 | }); |
| 334 | }, |
| 335 | |
| 336 | // 获取小红书话题流量榜 |
| 337 | getXhsSubjectsRank(data: { phone: string }) { |
| 338 | return hotHttp.post<string>('/xhs/contents', data, { |
| 339 | isToken: false, |
| 340 | }); |
| 341 | }, |
| 342 | |
| 343 | // 获取抖音榜单日期 |
| 344 | getDyDates() { |
| 345 | return hotHttp.get<string[]>(`/dy/dates`, { |
| 346 | isToken: false, |
| 347 | }); |
| 348 | }, |
| 349 | |
| 350 | // 获取AI工具榜数据 |
| 351 | getAiToolsRankingApi(data: GetAiToolsRankingApiParams) { |
| 352 | return hotHttp.post<GetAiToolsRankingApiRes>(`/products/ranking/ai`, { |
| 353 | ...data, |
| 354 | pageSize: 100, |
| 355 | area: +data.area, |
| 356 | }); |
| 357 | }, |
| 358 | }; |
| 359 |