添加api接口

master
liuyx 2 years ago
parent 50134ae9ad
commit 1559e9ebca

@ -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
})
}

@ -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
})
}

@ -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'
})
}

@ -1,8 +0,0 @@
import axios from 'axios'
const api = axios.create({
baseURL: '/api',
timeout: 3000
})
export default api

@ -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
})
}

@ -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'
})
}
Loading…
Cancel
Save