all.api.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. /**
  2. * 所有的接口
  3. */
  4. import {getPersonalToken} from '@/utils/token.js'
  5. import HttpHandler from '@/common/http/request.js'
  6. import qs from 'qs'
  7. import {getAppConfigs} from '@/config/index.js'
  8. export default {
  9. /**
  10. * 获取文章列表
  11. * @param {Object} params 参数
  12. */
  13. getPostList: (params) => {
  14. return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/posts`, params)
  15. },
  16. /**
  17. * 根据名称获取文章
  18. * @param {String} name 分类名称
  19. */
  20. getPostByName: (name) => {
  21. return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/posts/${name}`, {}, {
  22. header: {
  23. 'Wechat-Session-Id': uni.getStorageSync('openid'),
  24. }
  25. })
  26. },
  27. /**
  28. * 搜索文章
  29. * @param {Object} params 数据
  30. */
  31. getPostListByKeyword: (params) => {
  32. // return HttpHandler.Get(`/apis/api.halo.run/v1alpha1/indices/post`, params)
  33. return HttpHandler.Post(`/apis/api.halo.run/v1alpha1/indices/-/search`, params)
  34. },
  35. /**
  36. * 查询分类列表
  37. * @param {Object} params 查询参数
  38. */
  39. getCategoryList: (params) => {
  40. const param = qs.stringify(params, {
  41. allowDots: true,
  42. encodeValuesOnly: true,
  43. skipNulls: true,
  44. encode: false,
  45. arrayFormat: 'repeat'
  46. })
  47. return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/categories?${param}`, {})
  48. },
  49. /**
  50. * 查询分类下的文章
  51. * @param {String} name 分类名称
  52. * @param {Object} params 查询参数
  53. */
  54. getCategoryPostList: (name, params) => {
  55. return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/categories/${name}/posts`, params)
  56. },
  57. /**
  58. * 获取评论列表接口(列表数据)
  59. * @param {Object} params 查询参数
  60. */
  61. getPostCommentList: (params) => {
  62. return HttpHandler.Get(`/apis/api.halo.run/v1alpha1/comments`, params)
  63. },
  64. /**
  65. * 获取回复列表
  66. * @param {String} commentName 名称
  67. * @param {Object} params 查询参数
  68. */
  69. getPostCommentReplyList: (commentName, params) => {
  70. return HttpHandler.Get(`/apis/api.halo.run/v1alpha1/comments/${commentName}/reply`, params)
  71. },
  72. // 提交评论
  73. addPostComment: (data) => {
  74. return HttpHandler.Post(`/apis/api.halo.run/v1alpha1/comments`, data)
  75. },
  76. // 提交回复
  77. addPostCommentReply: (commentName, data) => {
  78. return HttpHandler.Post(`/apis/api.halo.run/v1alpha1/comments/${commentName}/reply`, data)
  79. },
  80. /**
  81. * 获取标签列表
  82. * @param {Object} params 查询参数
  83. */
  84. getTagList: (params) => {
  85. return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/tags`, params)
  86. },
  87. /**
  88. * 根据标签获取文章列表
  89. * @param {String} tagName 参数
  90. * @param {Object} params 查询参数
  91. */
  92. getPostByTagName: (tagName, params) => {
  93. return HttpHandler.Get(`/apis/api.content.halo.run/v1alpha1/tags/${tagName}/posts`, params)
  94. },
  95. /**
  96. * 获取瞬间列表
  97. */
  98. getMomentList: (params) => {
  99. return HttpHandler.Get(`/apis/moment.halo.run/v1alpha1/moments`, params, {
  100. custom: {
  101. personalToken: getPersonalToken()
  102. }
  103. })
  104. },
  105. /**
  106. * 查询站点统计信息
  107. */
  108. getBlogStatistics: () => {
  109. return HttpHandler.Get(`/apis/api.halo.run/v1alpha1/stats/-`, {})
  110. },
  111. /**
  112. * 获取相册分组
  113. */
  114. getPhotoGroupList: (params) => {
  115. return HttpHandler.Get(`/apis/core.halo.run/v1alpha1/photogroups`, params, {
  116. custom: {
  117. personalToken: getPersonalToken()
  118. }
  119. })
  120. },
  121. /**
  122. * 根据分组获取相册
  123. */
  124. getPhotoListByGroupName: (params) => {
  125. return HttpHandler.Get(`/apis/console.api.photo.halo.run/v1alpha1/photos`, params, {
  126. custom: {
  127. personalToken: getPersonalToken()
  128. }
  129. })
  130. },
  131. /**
  132. * 获取友链分组
  133. */
  134. getFriendLinkGroupList: (params) => {
  135. return HttpHandler.Get(`/apis/core.halo.run/v1alpha1/linkgroups`, params, {
  136. custom: {
  137. personalToken: getPersonalToken()
  138. }
  139. })
  140. },
  141. /**
  142. * 获取友链
  143. */
  144. getFriendLinkList: (params) => {
  145. return HttpHandler.Get(`/apis/api.plugin.halo.run/v1alpha1/plugins/PluginLinks/links`, params)
  146. },
  147. /**
  148. * 限制阅读校验
  149. * @param restrictType
  150. * @param code
  151. * @param keyId
  152. * @returns {HttpPromise<any>}
  153. */
  154. requestRestrictReadCheck: (restrictType, code, keyId) => {
  155. const params = {
  156. code: code,
  157. templateType: 'post',
  158. restrictType: restrictType,
  159. keyId: keyId
  160. }
  161. return HttpHandler.Post(`/apis/tools.muyin.site/v1alpha1/restrict-read/check`, params, {
  162. header: {
  163. 'Authorization': getAppConfigs().pluginConfig.toolsPlugin?.Authorization,
  164. 'Wechat-Session-Id': uni.getStorageSync('openid'),
  165. }
  166. })
  167. },
  168. /**
  169. * 获取文章验证码
  170. */
  171. createVerificationCode: () => {
  172. return HttpHandler.Get(`/apis/tools.muyin.site/v1alpha1/restrict-read/create`, null, {
  173. header: {
  174. 'Authorization': getAppConfigs().pluginConfig.toolsPlugin?.Authorization,
  175. 'Wechat-Session-Id': uni.getStorageSync('openid'),
  176. }
  177. })
  178. },
  179. /**
  180. * 提交友情链接
  181. */
  182. submitLink(form) {
  183. return HttpHandler.Post(`/apis/linksSubmit.muyin.site/v1alpha1/submit`, form, {
  184. header: {
  185. 'Authorization': getAppConfigs().pluginConfig.linksSubmitPlugin?.Authorization,
  186. 'Wechat-Session-Id': uni.getStorageSync('openid'),
  187. }
  188. })
  189. },
  190. /**
  191. * 获取二维码信息
  192. */
  193. getQRCodeInfo: (key) => {
  194. return HttpHandler.Get(`/apis/api.uni.uhalo.pro/v1alpha1/plugins/plugin-uni-halo/getQRCodeInfo/${key}`,
  195. null, {})
  196. },
  197. /**
  198. * 获取二维码图片
  199. */
  200. getQRCodeImg: (postId) => {
  201. return HttpHandler.Get(`/apis/api.uni.uhalo.pro/v1alpha1/plugins/plugin-uni-halo/getQRCodeImg/${postId}`,
  202. null, {})
  203. },
  204. /**
  205. * 点赞
  206. * @param {*} data ={group, plural, name}
  207. */
  208. submitUpvote(data) {
  209. return HttpHandler.Post(`/apis/api.halo.run/v1alpha1/trackers/upvote`, data, {})
  210. }
  211. }