1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
import request from '@/helpers/request.ts'
const URL = {
GET_LIST: '/blog',
GET_DETAIL: '/blog/:blogId',
CREATE: '/blog',
UPDATE: '/blog/:blogId',
DELETE: '/blog/:blogId'
}
export default {
getBlogs({ page = 1, userId, atIndex }: any = { page: 1 }) {
// 修改了
return request(URL.GET_LIST, 'GET', { page, userId, atIndex })
},
getIndexBlogs({ page = 1 } = { page: 1 }) {
return this.getBlogs({ page, atIndex: true })
},
getBlogsByUserId(userId: any, { page = 1, atIndex }: any = { page: 1 }, ) {
return this.getBlogs({ userId, page, atIndex })
},
getDetail({ blogId }: any) {
return request(URL.GET_DETAIL.replace(':blogId', blogId))
},
updateBlog({ blogId }: any, { title, content, description, atIndex }: any) {
return request(URL.UPDATE.replace(':blogId', blogId), 'PATCH', { title, content, description, atIndex })
},
deleteBlog({ blogId }: any) {
return request(URL.DELETE.replace(':blogId', blogId), 'DELETE')
},
createBlog({ title = "", content = "", description = "", atIndex = true }: any = { title: '', content: '', description: '', atIndex: true }) {
return request(URL.CREATE, 'POST', { title, content, description, atIndex })
}
}
|