import { CheckCircleOutlined, FlagOutlined, MailOutlined, PhoneOutlined } from "@ant-design/icons"; import { useEffect, useState, type FormEvent } from "react"; import { publicConfigClient, type WebPublicConfig } from "../../api/publicConfigClient"; import { reportClient, type ReportInput } from "../../api/reportClient"; import "../../styles/pages/compliance.css"; type SubmitState = "idle" | "loading" | "success" | "error"; const REPORT_TYPES = [ { value: "spam", label: "垃圾内容" }, { value: "abuse", label: "滥用 / 骚扰" }, { value: "copyright", label: "侵权 / 版权" }, { value: "illegal", label: "违法违规" }, { value: "other", label: "其他" }, ]; const TARGET_TYPES = [ { value: "project", label: "项目" }, { value: "community_post", label: "社区作品" }, { value: "user", label: "用户" }, { value: "comment", label: "评论" }, { value: "other", label: "其他" }, ]; function ReportPage() { const [reportType, setReportType] = useState(""); const [targetType, setTargetType] = useState(""); const [targetId, setTargetId] = useState(""); const [title, setTitle] = useState(""); const [description, setDescription] = useState(""); const [contactName, setContactName] = useState(""); const [contactEmail, setContactEmail] = useState(""); const [contactPhone, setContactPhone] = useState(""); const [submitState, setSubmitState] = useState("idle"); const [errorMsg, setErrorMsg] = useState(""); const [publicConfig, setPublicConfig] = useState({}); const canSubmit = submitState !== "loading" && reportType !== "" && title.trim() !== "" && description.trim() !== ""; const resetForm = () => { setReportType(""); setTargetType(""); setTargetId(""); setTitle(""); setDescription(""); setContactName(""); setContactEmail(""); setContactPhone(""); setSubmitState("idle"); setErrorMsg(""); }; useEffect(() => { let cancelled = false; publicConfigClient .get() .then((config) => { if (!cancelled) setPublicConfig(config); }) .catch(() => { if (!cancelled) setPublicConfig({}); }); return () => { cancelled = true; }; }, []); const handleSubmit = async (event: FormEvent) => { event.preventDefault(); if (!canSubmit) return; setSubmitState("loading"); setErrorMsg(""); try { const input: ReportInput = { reportType, targetType: targetType || undefined, targetId: targetId.trim() || undefined, title: title.trim(), description: description.trim(), contactName: contactName.trim() || undefined, contactEmail: contactEmail.trim() || undefined, contactPhone: contactPhone.trim() || undefined, pageUrl: window.location.href, }; await reportClient.submit(input); setSubmitState("success"); } catch (error: unknown) { setErrorMsg(error instanceof Error ? error.message : "提交失败,请稍后重试"); setSubmitState("error"); } }; return (

投诉举报

提交后会同步到服务器举报工单,工作人员会在审核台中查看处理。

{publicConfig.contactEmail || "由服务器配置"} {publicConfig.contactPhone || "由服务器配置"} {publicConfig.icpRecord || "由服务器配置"}
{submitState === "success" ? (

提交成功

感谢反馈,举报内容已进入服务器工单列表。

) : (