"use client"; import { useEffect, useState } from "react"; import { useParams } from "next/navigation"; import { api, type Pipeline } from "@/components/api"; import { PipelineForm } from "@/components/pipeline-form"; export default function EditPipelinePage() { const params = useParams<{ id: string }>(); const id = Number(params.id); const [pipeline, setPipeline] = useState(null); const [error, setError] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { api(`/api/pipelines/${id}`) .then(setPipeline) .catch((e) => setError(e instanceof Error ? e.message : "加载失败")) .finally(() => setLoading(false)); }, [id]); if (loading) return
加载中…
; if (error || !pipeline) return (
{error ? `加载失败:${error}` : "流水线不存在"}
); return ; }