"use client" import { useState } from "react" import { useRouter } from "next/navigation" import { BasicSettings } from "./components/basic-settings" import { TargetSelection } from "./components/target-selection" import { Card, CardContent } from "@/components/ui/card" import { Steps, Step } from "@/components/ui/steps" import { useToast } from "@/components/ui/use-toast" export default function CreateAnalyzerPage() { const router = useRouter() const { toast } = useToast() const [currentStep, setCurrentStep] = useState(0) const [formData, setFormData] = useState({ taskName: "", analysisTypes: [] as string[], targetType: "device", selectedDevices: [] as string[], selectedTrafficPool: "", tags: [] as string[], regions: [] as string[], keywords: [] as string[], }) const updateFormData = (data: Partial) => { setFormData((prev) => ({ ...prev, ...data })) } const handleNext = () => { setCurrentStep(1) } const handleBack = () => { setCurrentStep(0) } const handleSubmit = async () => { // 模拟提交 try { // 显示加载状态 toast({ title: "正在创建分析计划...", description: "请稍候", }) // 模拟API请求延迟 await new Promise((resolve) => setTimeout(resolve, 1500)) // 成功提示 toast({ title: "分析计划创建成功", description: "您可以在列表中查看分析进度", variant: "success", }) // 跳转回列表页 router.push("/workspace/ai-analyzer") } catch (error) { toast({ title: "创建失败", description: "请稍后重试", variant: "destructive", }) } } const steps = [ { id: "basic", title: "基础设置" }, { id: "target", title: "选择分析对象" }, ] return (
{steps.map((step, index) => ( ))}
{currentStep === 0 && ( )} {currentStep === 1 && ( )}
) }