Skip to content

Let's use AI to Earn!

style: 1

牛文政00c629f67b97
diff --git a/src/api/platform.ts b/src/api/platform.ts
index b84323a7..eeb578d9 100644
--- a/src/api/platform.ts
+++ b/src/api/platform.ts
@@ -1,4 +1,8 @@
import http from './request';
+import { Pagination } from './types';
+import { HotTopic } from './types/hotTopic';
+import { Topic } from './types/topic';
+import { ViralTitle } from './types/viralTitles';
export interface Platform {
id: string;
@@ -105,6 +109,11 @@ export interface RankingContentsResponse {
meta: PaginationMeta;
}
+export interface RankingContentsResponse {
+ items: RankingContent[];
+ meta: PaginationMeta;
+}
+
export const platformApi = {
// 获取平台列表
getPlatformList() {
@@ -143,4 +152,95 @@ export const platformApi = {
isToken: false,
});
},
+
+ // 获取所有热点事件
+ getAllHotTopics() {
+ return http.get<
+ {
+ platform: Platform;
+ hotTopic: HotTopic;
+ }[]
+ >(`/hot-topics/all`, {
+ isToken: false,
+ });
+ },
+
+ // ---- 热门专题 ----
+
+ // 获取所有专题分类
+ getTopicCategories() {
+ return http.get<string[]>(`/topics/categories`, {
+ isToken: false,
+ });
+ },
+
+ // 获取子分类列表
+ getSubCategories(category?: string) {
+ return http.get<string[]>(`/topics/sub-categories`, {
+ isToken: false,
+ params: {
+ category,
+ },
+ });
+ },
+ // 获取所有热点事件
+ getAllTopics(params: {
+ category?: string;
+ subCategory?: string;
+ startTime?: string;
+ endTime?: string;
+ topic?: string;
+ }) {
+ return http.get<Pagination<Topic>>(`/topics`, {
+ isToken: false,
+ params,
+ });
+ },
+
+ // 获取所有话题标签
+ getTopics() {
+ return http.get<string[]>(`/topics/topics`, {
+ isToken: false,
+ });
+ },
+
+ // ---- 爆款标题 ----
+ // 获取有数据的平台列表
+ findPlatformsWithData() {
+ return http.get<Platform[]>(`/viral-titles/platforms`, {
+ isToken: false,
+ });
+ },
+
+ // 获取指定平台的分类列表
+ findCategoriesByPlatform(platformId: string) {
+ return http.get<string[]>(
+ `/viral-titles/platforms/${platformId}/categories`,
+ {
+ isToken: false,
+ },
+ );
+ },
+
+ // 获取平台下所有分类的前五条数据
+ findTopByPlatformAndCategories(platformId: string) {
+ return http.get<
+ {
+ category: string;
+ titles: ViralTitle[];
+ }[]
+ >(`/viral-titles/platforms/${platformId}/top-by-categories`, {
+ isToken: false,
+ });
+ },
+
+ // 获取平台下指定分类的数据列表(分页)
+ findByPlatformAndCategory(platformId: string) {
+ return http.get<Pagination<ViralTitle>>(
+ `/viral-titles/platforms/${platformId}/top-by-categories`,
+ {
+ isToken: false,
+ },
+ );
+ },
};
diff --git a/src/api/types/hotTopic.ts b/src/api/types/hotTopic.ts
new file mode 100644
index 00000000..95f2b1e5
--- /dev/null
+++ b/src/api/types/hotTopic.ts
@@ -0,0 +1,21 @@
+import { Platform } from '../platform';
+
+interface HotValueHistory {
+ timestamp: Date; // 记录时间
+ value: number; // 热度值
+}
+
+export interface HotTopic {
+ _id: string;
+ platformId: Platform; // 关联平台ID
+ title: string; // 话题标题
+ hotValue: number; // 当前热度值
+ url: string; // 话题链接
+ rank: number; // 当前排名
+ rankChange: number; // 排名变化值(正数表示上升,负数表示下降)
+ isRising: boolean; // 是否上升趋势
+ hotValueHistory: HotValueHistory[]; // 热度值历史记录
+ fetchTime: Date; // 数据抓取时间
+ createTime: Date;
+ updateTime: Date;
+}
diff --git a/src/api/types/topic.ts b/src/api/types/topic.ts
new file mode 100644
index 00000000..673d2153
--- /dev/null
+++ b/src/api/types/topic.ts
@@ -0,0 +1,19 @@
+export interface Topic {
+ _id: string;
+ title: string; // 话题标题
+ description?: string;
+ category: string;
+ subCategory: string;
+ url: string; // 作品链接
+ author?: string; // 作者
+ topics: string[]; // 话题标签
+ rank: number;
+ coverUrl?: string;
+ shareCount: number;
+ likeCount: number;
+ watchingCount: number;
+ readCount: number;
+ publishTime?: Date;
+ createTime: Date;
+ updateTime: Date;
+}
diff --git a/src/api/types/viralTitles.ts b/src/api/types/viralTitles.ts
new file mode 100644
index 00000000..eab1e5a5
--- /dev/null
+++ b/src/api/types/viralTitles.ts
@@ -0,0 +1,14 @@
+import { Platform } from '../platform';
+
+export interface ViralTitle {
+ _id: string;
+ platformId: Platform;
+ category: string;
+ title: string;
+ url: string; // 链接
+ rank: number; // 排名
+ engagement: number; // 互动量
+ publishTime?: Date;
+ createTime: Date;
+ updateTime: Date;
+}
diff --git a/src/router/index.tsx b/src/router/index.tsx
index 848c9284..fc6c8240 100644
--- a/src/router/index.tsx
+++ b/src/router/index.tsx
@@ -40,6 +40,7 @@ import Statistics from '@/views/statistics';
import Test from '@/views/test/index';
import TestVideo from '@/views/test/video';
import Task from '@/views/task';
+import HotTopic from '@/views/trending/hotTopic';
interface IRouterMeta {
// 路由名称
@@ -177,6 +178,10 @@ export const router: CustomRouteObject[] = [
path: 'xiaohongshu',
element: <Xiaohongshu />,
},
+ {
+ path: 'hotTopic',
+ element: <HotTopic />,
+ },
],
},
],
diff --git a/src/views/test/index.tsx b/src/views/test/index.tsx
index d244651c..75ed5194 100644
--- a/src/views/test/index.tsx
+++ b/src/views/test/index.tsx
@@ -1,7 +1,7 @@
/*
* @Author: nevin
* @Date: 2025-02-10 22:20:15
- * @LastEditTime: 2025-02-22 18:20:33
+ * @LastEditTime: 2025-02-26 21:50:26
* @LastEditors: nevin
* @Description: 测试页面
*/
@@ -33,6 +33,11 @@ export default function Page() {
},
{ label: '视频测试', value: 'video', icon: <VideoCameraOutlined /> },
{ label: '任务测试', value: 'video', icon: <VideoCameraOutlined /> },
+ {
+ label: '热门事件',
+ value: 'hotTopic',
+ icon: <VideoCameraOutlined />,
+ },
]}
onChange={(value) => {
navigate(value);
diff --git a/src/views/trending/hotTopic.tsx b/src/views/trending/hotTopic.tsx
new file mode 100644
index 00000000..d3cd0667
--- /dev/null
+++ b/src/views/trending/hotTopic.tsx
@@ -0,0 +1,28 @@
+/*
+ * @Author: nevin
+ * @Date: 2025-02-26 21:43:19
+ * @LastEditTime: 2025-02-26 21:43:30
+ * @LastEditors: nevin
+ * @Description: 热门事件
+ */
+
+import { platformApi } from '@/api/platform';
+import React from 'react';
+
+const Page: React.FC = () => {
+ async function getAllHotTopics() {
+ const res = await platformApi.getAllHotTopics();
+ console.log('----', res);
+ }
+
+ // 获取热门事件
+ getAllHotTopics();
+
+ return (
+ <>
+ <div>热门内容</div>
+ </>
+ );
+};
+
+export default Page;