| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- /**
- * 文章接口
- * @see https://api.halo.run/content-api.html#tag/post-controller
- */
- import HttpHandler from '@/common/http/request.js'
- export default {
- /**
- * 获取文章列表
- * @param {Object} params 参数
- */
- getPostList: (params) => {
- return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/posts`, params)
- },
- /**
- * 根据名称获取文章
- * @param {String} name 分类名称
- */
- getPostByName: (name) => {
- return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/posts/${name}`, {})
- },
- /**
- * 评论文章
- * @param {Object} data 数据
- * {
- * "allowNotification": true,
- * "author": "string",
- * "authorUrl": "string",
- * "content": "string",
- * "email": "string",
- * "parentId": 0,
- * "postId": 0
- * }
- */
- postCommentPost: (data) => {
- return HttpHandler.Post(`/api/content/posts/comments`, data)
- },
- /**
- * 搜索文章
- * @param {Object} data 数据
- */
- getPostListByKeyword: (data) => {
- return HttpHandler.Post(`/api/content/posts/search`, data)
- },
- /**
- * 根据分类获取文章
- * @param {Object} params 参数
- */
- getPostDetailBySlug: (params) => {
- return HttpHandler.Get(`/api/content/posts/slug`, params)
- },
- /**
- * 根据文章id获取文章
- * @param {Object} params 参数
- */
- getPostDetailByPostId: (postId, params) => {
- return HttpHandler.Get(`/api/content/posts/${postId}`, params)
- },
- /**
- * 给文章点赞
- * @param {Object} postId 文章id
- */
- postLikePost: (postId) => {
- return HttpHandler.Post(`/api/content/posts/${postId}/likes`)
- },
- /**
- * 根据当前文章id获取前一篇文章
- * @param {Object} postId 文章id
- */
- getPrevByCurrentPostId: (postId) => {
- return HttpHandler.Get(`/api/content/posts/${postId}/prev`)
- },
- /**
- * 根据当前文章id获取下一篇文章
- * @param {Object} postId 文章id
- */
- getNextByCurrentPostId: (postId) => {
- return HttpHandler.Get(`/api/content/posts/${postId}/next`)
- },
- }
|