初步完成评论

This commit is contained in:
2025-06-07 03:21:27 +08:00
parent 11add3c1fa
commit 96316e3d51
12 changed files with 208 additions and 4 deletions

View File

@@ -0,0 +1,15 @@
import fetcher from "../fetcher";
export async function createComment(blogId: string, content: string) {
return fetcher<{
blogId: string;
content: string;
createdAt: string
deletedAt: null; // 原则上能看到就是null
id: string;
parentId: string | null;
}>(`/api/blog/${blogId}/comment`, {
method: 'POST',
body: JSON.stringify({ content }),
});
}

View File

@@ -0,0 +1,13 @@
import fetcher from "../fetcher";
export async function getComments(blogId: string) {
return fetcher<{
blogId: string;
content: string;
createdAt: string;
deletedAt: string | null;// 原则上能看到就是null
id: string;
parentId: string | null; // 如果是回复则有parentId
user: null;// TODO需要完善
}[]>(`/api/blog/${blogId}/comments`, { method: 'GET' });
}

View File

@@ -1,2 +1,4 @@
export * from './list';
export * from './get';
export * from './get';
export * from './getComments';
export * from './createComment';

View File

@@ -3,4 +3,5 @@ export * as verificationApi from './verification/index';
export * as AdminApi from './admin/index';
export * as ResourceApi from './resource/index';
export * as BlogApi from './blog/index';
export * as UserApi from './user/index';
export * as UserApi from './user/index';
export * as OssApi from './oss/index';