"use client"; import { useState } from "react"; interface ReplyFormProps { topicId: number; isLocked: boolean; } export function ReplyForm({ topicId, isLocked }: ReplyFormProps) { const [submitting, setSubmitting] = useState(false); if (isLocked) { return (

此话题已锁定,无法回复

); } return (
{ e.preventDefault(); setSubmitting(true); const formData = new FormData(e.currentTarget); const content = formData.get("content") as string; if (!content.trim()) { setSubmitting(false); return; } const res = await fetch(`/api/forum/topics/${topicId}/posts`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ content }), }); setSubmitting(false); if (res.ok) { window.location.reload(); } }} className="rounded-xl border border-border/50 bg-white p-5 shadow-[0_1px_2px_rgba(0,0,0,0.04)]" >

发表回复