Files
rainblogweb/frontend/src/api/blog.js
T

31 lines
1.1 KiB
JavaScript

import { request } from './client.js';
/** 文章列表;all=true 返回全部(含草稿,仅管理员) */
export function listPosts(all) {
return request('/blog/posts' + (all ? '?all=1' : ''));
}
export function getPost(id) {
return request('/blog/posts/' + id);
}
/** data = { title, content, excerpt?, published?, use_markdown? }(仅管理员) */
export function createPost(data) {
return request('/blog/posts', { method: 'POST', body: data });
}
export function updatePost(id, data) {
return request('/blog/posts/' + id, { method: 'PUT', body: data });
}
export function deletePost(id) {
return request('/blog/posts/' + id, { method: 'DELETE' });
}
// ── 评论 ────────────────────────────────────────
export function listComments(postId) {
return request('/blog/comments/' + postId);
}
export function createComment(postId, content) {
return request('/blog/comments/' + postId, { method: 'POST', body: { content } });
}
export function deleteComment(id) {
return request('/blog/comments/' + id, { method: 'DELETE' });
}