article.js
4.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import { fn, fetch } from '@/api/fn';
const Api = {
ArticleDetail: '/srv/?a=article&t=article_detail',
Favorite: '/srv/?a=article&t=favorite',
List: '/srv/?a=article&t=list',
WeekHot: '/srv/?a=article&t=week_hot',
}
/**
* @description 文章详情
* @remark
* @param {Object} params 请求参数
* @param {string} params.i (可选)
* @returns {Promise<{
* code: number; // 状态码
* msg: string; // 消息
* data: {
id: integer; // 文章id
post_title: string; // 标题
post_content: string; // 内容
post_excerpt: string; // 简介
post_link: string; // 外部链接
post_date: string; // 发布日期
post_author: integer; // 发布人id
author_name: string; // 发布人
is_favorite: integer; //
* };
* } >}
*/
export const articleDetailAPI = (params) => fn(fetch.get(Api.ArticleDetail, params));
/**
* @description 文章收藏列表
* @remark
* @param {Object} params 请求参数
* @param {string} params.limit (可选)
* @param {string} params.page (可选)
* @param {string} params.keyword (可选) 搜索关键词
* @returns {Promise<{
* code: number; // 状态码
* msg: string; // 消息
* data: {
list: Array<{
id: integer; //
post_title: string; // 文章表头
post_excerpt: string; // 简介
post_link: string; // 外部链接
post_date: string; // 发布时间
favorite_time: string; // 收藏时间
}>;
total: integer; //
* };
* }>}
*/
export const favoriteAPI = (params) => fn(fetch.get(Api.Favorite, params));
/**
* @description 文章列表
* @remark
* @param {Object} params 请求参数
* @param {string} params.limit (可选)
* @param {string} params.page (可选)
* @param {string} params.cid (可选) 分类id
* @param {string} params.child_id (可选) 只有一层分类时,筛选数据用
* @param {string} params.keyword (可选) 搜索关键词
* @returns {Promise<{
* code: number; // 状态码
* msg: string; // 消息
* data: {
cate: {
id: integer; // 分类id
category_name: string; // 分类名称
category_parent: integer; // 分类父级
category_description: null; // 分类描述
};
children: Array<{
id: integer; // 二级分类id
category_name: string; // 二级分类名
category_parent: integer; // 二级分类名父级id
level: integer; //
category_description: null; // 二级分类描述
icon: null; //
max_depth: integer; //
list: Array<{
name: string; // 附件名称
value: string; // 附件地址
extension: string; // 后缀名
post_date: string; // 发布时间
size: string; // 附件大小
is_favorite: integer; // 是否收藏
id: string; // 附件id
}>;
children: Array<{
id: integer; // 三级分类id
category_name: string; // 三级分类名
category_parent: integer; // 三级分类名父级id
category_description: null; // 三级分类描述
icon: string; // 二级分类图标
}>;
}>;
list: Array<{
id: integer; //
post_title: string; // 标题
post_excerpt: string; // 简介
post_link: string; // 如果有就是去外部链接
post_date: string; // 发布时间
is_favorite: integer; // 是否收藏
}>;
total: integer; // 主分类文章数量
max_level: integer; // 页面需要层级
* };
* }>}
*/
export const listAPI = (params) => fn(fetch.get(Api.List, params));
/**
* @description 热门文章
* @remark
* @param {Object} params 请求参数
* @param {string} params.limit (可选)
* @param {string} params.page (可选)
* @param {string} params.cid (可选) 分类id
* @param {string} params.keyword (可选) 搜索关键词
* @returns {Promise<{
* code: number; // 状态码
* msg: string; // 消息
* data: {
list: Array<{
id: integer; //
post_title: string; // 标题
post_excerpt: null; // 简介
post_link: string; // 外部链接
post_date: string; // 发布日期
is_favorite: integer; // 是否收藏
read_people_count: string; // 学习人数
read_people_percent: string; // 学习人数比例
}>;
total: integer; //
* };
* }>}
*/
export const weekHotAPI = (params) => fn(fetch.get(Api.WeekHot, params));