diff --git a/src/api/ArticleAPI.ts b/src/api/ArticleAPI.ts new file mode 100644 index 0000000..8c32aed --- /dev/null +++ b/src/api/ArticleAPI.ts @@ -0,0 +1,26 @@ +import { ArticleView, axios } from "timi-web"; + +/** + * 获取文章 + * + * @param id 文章 ID + * @returns 文章数据 + */ +async function view(id: number): Promise> { + return axios.get(`/article/${id}`); +} + +/** + * 喜欢文章,后端有限调用,1240ms 一次 + * + * @param id 文章 ID + * @returns 最新喜欢数量 + */ +async function like(id: number): Promise { + return axios.get(`/article/like/${id}`); +} + +export default { + view, + like, +}; diff --git a/src/index.ts b/src/index.ts index f150223..87898c3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,6 +5,7 @@ import components from "./components"; import Network from "./utils/Network"; import UserAPI from "./api/UserAPI"; import CommonAPI from "./api/CommonAPI"; +import ArticleAPI from "./api/ArticleAPI"; import CommentAPI from "./api/CommentAPI"; import DeveloperAPI from "./api/DeveloperAPI"; @@ -67,6 +68,7 @@ export { UserAPI, CommonAPI, + ArticleAPI, CommentAPI, DeveloperAPI,