From 1559e9ebca1d91c6cbed7ec9ca16b2787b4e70af Mon Sep 17 00:00:00 2001 From: liuyx <1517482303@qq.com> Date: Wed, 28 Dec 2022 14:36:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0api=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/src/api/about.js | 15 +++++++++++++ admin/src/api/article.js | 46 +++++++++++++++++++++++++++++++++++++++ admin/src/api/category.js | 36 ++++++++++++++++++++++++++++++ admin/src/api/index.js | 8 ------- admin/src/api/site.js | 22 +++++++++++++++++++ admin/src/api/tag.js | 36 ++++++++++++++++++++++++++++++ 6 files changed, 155 insertions(+), 8 deletions(-) create mode 100644 admin/src/api/about.js create mode 100644 admin/src/api/article.js create mode 100644 admin/src/api/category.js delete mode 100644 admin/src/api/index.js create mode 100644 admin/src/api/site.js create mode 100644 admin/src/api/tag.js diff --git a/admin/src/api/about.js b/admin/src/api/about.js new file mode 100644 index 0000000..c2ef35c --- /dev/null +++ b/admin/src/api/about.js @@ -0,0 +1,15 @@ +import request from '@/utils/request.js' + +export const getAboutContent = () => { + return request({ + url: '/about' + }) +} + +export const updateAboutContent = (data) => { + return request({ + url: '/about', + method: 'put', + data + }) +} diff --git a/admin/src/api/article.js b/admin/src/api/article.js new file mode 100644 index 0000000..23ec442 --- /dev/null +++ b/admin/src/api/article.js @@ -0,0 +1,46 @@ +import request from '@/utils/request.js' + +// 获取所有文章 +export const getArticleList = (currentPage, pageSize) => { + return request({ + url: '/articles', + method: 'get', + params: { + currentPage, + pageSize + } + }) +} + +// 根据id获取文章 +export const getArticleById = (id) => { + return request({ + url: `/articles/${id}` + }) +} + +// 发布文章 +export const postArticle = (data) => { + return request({ + url: '/articles', + method: 'post', + data + }) +} + +// 根据id删除文章 +export const deleteArticleById = (id) => { + return request({ + url: `/articles/${id}`, + method: 'delete' + }) +} + +// 批量删除文章 +export const deleteMutipleArticle = (data) => { + return request({ + url: '/articles', + method: 'delete', + data + }) +} diff --git a/admin/src/api/category.js b/admin/src/api/category.js new file mode 100644 index 0000000..b577763 --- /dev/null +++ b/admin/src/api/category.js @@ -0,0 +1,36 @@ +import request from '@/utils/request.js' + +// 获取分类列表 +export const getCategoryList = () => { + return request({ + url: '/categories' + }) +} + +// 根据id获取分类 +export const getCategoryById = (id) => { + return request({ + url: `/categories/${id}` + }) +} + +/** + * 新增or修改分类 + * @param {*} data categories表单 + * @returns axios响应结果 + */ +export const updateCategory = (data) => { + return request({ + url: '/categories', + method: 'post', + data + }) +} + +// 根据id删除分类 +export const deleteCategoryById = (id) => { + return request({ + url: `/categories/${id}`, + method: 'delete' + }) +} diff --git a/admin/src/api/index.js b/admin/src/api/index.js deleted file mode 100644 index 0a58f00..0000000 --- a/admin/src/api/index.js +++ /dev/null @@ -1,8 +0,0 @@ -import axios from 'axios' - -const api = axios.create({ - baseURL: '/api', - timeout: 3000 -}) - -export default api diff --git a/admin/src/api/site.js b/admin/src/api/site.js new file mode 100644 index 0000000..db1db7d --- /dev/null +++ b/admin/src/api/site.js @@ -0,0 +1,22 @@ +/* + * @Author: liuyx 1517482303@qq.com + * @Date: 2022-12-17 08:42:16 + * @LastEditTime: 2022-12-17 09:43:32 + * @Description: 网站信息API + */ +import request from '@/utils/request.js' + +// 获取网站信息 +export const getSiteInfo = () => { + return request({ + url: '/sites' + }) +} + +export const updateSiteInfo = (data) => { + return request({ + url: '/sites', + method: 'put', + data + }) +} diff --git a/admin/src/api/tag.js b/admin/src/api/tag.js new file mode 100644 index 0000000..4e6b915 --- /dev/null +++ b/admin/src/api/tag.js @@ -0,0 +1,36 @@ +import request from '@/utils/request.js' + +// 获取标签列表 +export const getTagList = () => { + return request({ + url: '/tags' + }) +} + +// 根据id获取标签 +export const getTagById = (id) => { + return request({ + url: `/tags/${id}` + }) +} + +/** + * 新增or修改标签 + * @param {*} data tag表单 + * @returns axios响应结果 + */ +export const updateTag = (data) => { + return request({ + url: '/tags', + method: 'post', + data + }) +} + +// 根据id删除标签 +export const deleteTagById = (id) => { + return request({ + url: `/tags/${id}`, + method: 'delete' + }) +}