"use client" import { useState, useEffect } from "react" import { Button } from "@/components/ui/button" import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { ArrowLeft, Plus, FileText, BarChart2, Mail } from "lucide-react" import { useRouter } from "next/navigation" import { Badge } from "@/components/ui/badge" import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs" import Link from "next/link" interface AnalysisPlan { id: string name: string wechatId: string deviceName: string status: "running" | "completed" | "failed" createdAt: string completedAt?: string keywords: string[] type: "friends" | "moments" | "both" | "behavior" } export default function AIAnalyzerPage() { const router = useRouter() const [plans, setPlans] = useState([]) const [isLoading, setIsLoading] = useState(true) useEffect(() => { // 模拟加载数据 const fetchPlans = async () => { await new Promise((resolve) => setTimeout(resolve, 1000)) const mockPlans: AnalysisPlan[] = [ { id: "plan-1", name: "美妆用户分析", wechatId: "wxid_abc123", deviceName: "设备1", status: "completed", createdAt: "2023-12-15T10:30:00Z", completedAt: "2023-12-15T11:45:00Z", keywords: ["美妆", "护肤", "彩妆"], type: "both", }, { id: "plan-2", name: "健身爱好者分析", wechatId: "wxid_fit456", deviceName: "设备2", status: "running", createdAt: "2023-12-16T09:15:00Z", keywords: ["健身", "运动", "健康"], type: "friends", }, { id: "plan-3", name: "教育行业分析", wechatId: "wxid_edu789", deviceName: "设备3", status: "completed", createdAt: "2023-12-14T14:20:00Z", completedAt: "2023-12-14T16:10:00Z", keywords: ["教育", "培训", "学习"], type: "moments", }, { id: "plan-4", name: "用户行为分析", wechatId: "wxid_beh123", deviceName: "设备4", status: "completed", createdAt: "2023-12-18T08:20:00Z", completedAt: "2023-12-18T10:15:00Z", keywords: ["活跃度", "互动", "转化"], type: "behavior", }, ] setPlans(mockPlans) setIsLoading(false) } fetchPlans() }, []) const getStatusBadge = (status: AnalysisPlan["status"]) => { switch (status) { case "running": return ( 分析中 ) case "completed": return ( 已完成 ) case "failed": return ( 失败 ) } } const getTypeLabel = (type: AnalysisPlan["type"]) => { switch (type) { case "friends": return "好友信息分析" case "moments": return "朋友圈内容分析" case "both": return "综合分析" case "behavior": return "用户行为分析" } } return (
{/* 头部 */}

AI数据分析

{/* 主内容区域 */}
全部计划 进行中 已完成 {isLoading ? (
) : plans.length > 0 ? ( plans.map((plan) => (
{plan.name} 设备: {plan.deviceName} | 微信号: {plan.wechatId}
{getStatusBadge(plan.status)}
分析类型 {getTypeLabel(plan.type)}
关键词
{plan.keywords.map((keyword, index) => ( {keyword} ))}
创建时间 {new Date(plan.createdAt).toLocaleString()}
{plan.completedAt && (
完成时间 {new Date(plan.completedAt).toLocaleString()}
)}
{plan.status === "completed" && ( <> )} {plan.status === "running" && ( )}
)) ) : (

暂无分析计划

创建一个新的AI数据分析计划来开始

)}
{isLoading ? (
) : plans.filter((p) => p.status === "running").length > 0 ? ( plans .filter((p) => p.status === "running") .map((plan) => (
{plan.name} 设备: {plan.deviceName} | 微信号: {plan.wechatId}
{getStatusBadge(plan.status)}
分析类型 {getTypeLabel(plan.type)}
关键词
{plan.keywords.map((keyword, index) => ( {keyword} ))}
创建时间 {new Date(plan.createdAt).toLocaleString()}
)) ) : (

暂无进行中的分析计划

)}
{isLoading ? (
) : plans.filter((p) => p.status === "completed").length > 0 ? ( plans .filter((p) => p.status === "completed") .map((plan) => (
{plan.name} 设备: {plan.deviceName} | 微信号: {plan.wechatId}
{getStatusBadge(plan.status)}
分析类型 {getTypeLabel(plan.type)}
关键词
{plan.keywords.map((keyword, index) => ( {keyword} ))}
创建时间 {new Date(plan.createdAt).toLocaleString()}
{plan.completedAt && (
完成时间 {new Date(plan.completedAt).toLocaleString()}
)}
)) ) : (

暂无已完成的分析计划

)}
) }