import React, { useState, useEffect } from "react"; import { Form, Input, Select, Button, Card, Descriptions, Tag, message, Spin, Row, Col, Tooltip } from "antd"; import { useParams, useNavigate, useLocation } from "react-router-dom"; import { ArrowLeftOutlined, CopyOutlined } from "@ant-design/icons"; import { autoAccessTasksApi } from "../services/api"; import moment from "moment"; import { STATUS_MAP, STATUS_TAG_COLOR } from "./AutoAccessTaskList"; const { TextArea } = Input; const { Option } = Select; // 状态枚举 const STATUS_OPTIONS = [ { value: 0, label: "待执行" }, { value: 1, label: "执行中" }, { value: 2, label: "已完成" }, { value: 3, label: "失败" }, { value: 4, label: "已注册" }, { value: 5, label: "待审核" }, { value: 6, label: "审核不通过" }, ]; // 状态映射(用于显示) const AutoAccessTaskDetail = () => { const [form] = Form.useForm(); const [data, setData] = useState(null); const [loading, setLoading] = useState(true); const [saving, setSaving] = useState(false); const { id } = useParams(); const navigate = useNavigate(); const location = useLocation(); const isEditMode = location.search.includes("mode=edit"); const getStatusColor = (status) => { return STATUS_TAG_COLOR[status] || "default"; }; const getStatusText = (status) => { return STATUS_MAP[status] || "未知"; }; const getAccessTypeText = (type) => { const typeMap = { api_no_crack: "API无破解", api_crack: "API破解", browser_auto_operate: "浏览器自动操作", }; return typeMap[type] || type; }; const fetchData = async () => { try { const response = await autoAccessTasksApi.getDetail(id); setData(response.data); form.setFieldsValue(response.data); } catch (error) { message.error("获取详情失败"); } finally { setLoading(false); } }; const handleSave = async (values) => { setSaving(true); try { await autoAccessTasksApi.update(id, values); message.success("更新成功"); navigate("/auto-access-tasks"); } catch (error) { message.error("更新失败"); } finally { setSaving(false); } }; const handleCopyApiDoc = () => { const apiDoc = form.getFieldValue("api_doc"); if (apiDoc) { navigator.clipboard .writeText(apiDoc) .then(() => { message.success("API文档已复制到剪贴板"); }) .catch(() => { message.error("复制失败,请手动复制"); }); } else { message.warning("API文档为空,无法复制"); } }; useEffect(() => { fetchData(); }, [id]); if (loading) { return (
{data.api_doc || "无"}
{data.operate_path_data || "无"}