From 2627c85ec5dafaf6f94d95579f315cf70e4c40e0 Mon Sep 17 00:00:00 2001 From: tone <3341154833@qq.com> Date: Sat, 7 Jun 2025 13:49:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E8=AF=84=E8=AE=BA=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../blog/[id]/components/BlogCommentTool.tsx | 8 +++++--- .../blog/[id]/components/BlogComments.tsx | 19 +++++++++++++++---- tone-page-web/lib/api/blog/createComment.ts | 10 ++-------- tone-page-web/lib/api/blog/getComments.ts | 11 ++--------- tone-page-web/lib/types/blogComment.ts | 11 +++++++++++ 5 files changed, 35 insertions(+), 24 deletions(-) create mode 100644 tone-page-web/lib/types/blogComment.ts diff --git a/tone-page-web/app/(with-header-footer)/blog/[id]/components/BlogCommentTool.tsx b/tone-page-web/app/(with-header-footer)/blog/[id]/components/BlogCommentTool.tsx index e73cd04..46f01e3 100644 --- a/tone-page-web/app/(with-header-footer)/blog/[id]/components/BlogCommentTool.tsx +++ b/tone-page-web/app/(with-header-footer)/blog/[id]/components/BlogCommentTool.tsx @@ -3,26 +3,28 @@ import { Button } from "@/components/ui/button"; import { Textarea } from "@/components/ui/textarea"; import { BlogApi } from "@/lib/api"; +import { BlogComment } from "@/lib/types/blogComment"; import { Send } from "lucide-react"; import { useState } from "react"; import { toast } from "sonner"; -export function BlogCommentTool({ blogId }: { blogId: string }) { +export function BlogCommentTool({ blogId, onInsertComment }: { blogId: string, onInsertComment: (b: BlogComment) => void }) { const [comment, setComment] = useState(''); const submit = async () => { + if (comment.trim().length === 0) return; const res = await BlogApi.createComment(blogId, comment); if (res) { toast.success('发布成功'); setComment(''); - // 提交界面刷新 + onInsertComment(res); } } return (