refactor: 重构并修复博客相关API
This commit is contained in:
@@ -49,4 +49,5 @@ export * as AuthAPI from './endpoints/auth.client'
|
||||
export * as UserAPI from './endpoints/user.client'
|
||||
export * as SmsAPI from './endpoints/sms.client'
|
||||
export * as AdminAPI from './endpoints/admin.client'
|
||||
export * as OSSAPI from './endpoints/oss.client'
|
||||
export * as OSSAPI from './endpoints/oss.client'
|
||||
export * as BlogAPI from './endpoints/blog.client'
|
||||
25
apps/frontend/lib/api/endpoints/blog.client.ts
Normal file
25
apps/frontend/lib/api/endpoints/blog.client.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { BlogComment } from "@/lib/types/blogComment";
|
||||
import { clientFetch } from "../client";
|
||||
|
||||
export async function getBlog(id: string, password?: string) {
|
||||
return clientFetch<{
|
||||
id: string;
|
||||
title: string;
|
||||
createdAt: string;
|
||||
content: string;
|
||||
}>(`/api/blog/${id}` + (password ? `?p=${password}` : ''));
|
||||
}
|
||||
|
||||
export async function getComments(id: string) {
|
||||
return clientFetch<BlogComment[]>(`/api/blog/${id}/comments`);
|
||||
}
|
||||
|
||||
export async function createComment(blogId: string, content: string, parentId?: string) {
|
||||
return clientFetch<BlogComment>(`/api/blog/${blogId}/comment`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
content,
|
||||
parentId: parentId || null,
|
||||
}),
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user