"use client" import { useState, useEffect } from "react" import { useParams, useRouter } from "next/navigation" import { DashboardShell } from "@/components/dashboard-shell" import { DashboardHeader } from "@/components/dashboard-header" import { Button } from "@/components/ui/button" import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs" import { Badge } from "@/components/ui/badge" import { useToast } from "@/hooks/use-toast" import { AddDanceDialog } from "@/components/dances/add-dance-dialog" import { DeleteConfirmationDialog } from "@/components/delete-confirmation-dialog" import { ArrowLeft, Download, Edit, Play, Upload, FileText, AlertTriangle } from "lucide-react" import type { Dance } from "@/lib/api/types" // 模拟获取舞蹈详情的API const getDanceById = async (id: string): Promise => { // 模拟API延迟 await new Promise((resolve) => setTimeout(resolve, 500)) // 模拟舞蹈数据 const mockDances: Dance[] = [ { id: "1", name: "千本樱", choreographer: "洛天依工作室", duration: "3:45", difficulty: "中等", videoUrl: "/placeholder.svg?height=300&width=400", coverUrl: "/placeholder.svg?height=300&width=400", description: "基于《千本樱》歌曲的经典舞蹈编排,动作流畅优美,适合中等水平的舞者。", motionFile: "senbonzakura_motion.fbx", category: "日式", tags: ["经典", "流行", "日式"], createdAt: "2023-01-15T08:30:00Z", updatedAt: "2023-02-20T14:15:00Z", status: "已发布", activatedCount: 1245, printedCount: 2000, }, { id: "2", name: "权御天下", choreographer: "洛天依动作组", duration: "4:20", difficulty: "高级", videoUrl: "/placeholder.svg?height=300&width=400", coverUrl: "/placeholder.svg?height=300&width=400", description: "中国风舞蹈,动作幅度大,需要较高的舞蹈基础,展现古风韵味。", motionFile: "quanyutianxia_motion.fbx", category: "中国风", tags: ["高难度", "中国风", "古风"], createdAt: "2023-03-10T10:45:00Z", updatedAt: "2023-04-05T16:30:00Z", status: "已发布", activatedCount: 1823, printedCount: 3000, }, { id: "3", name: "达拉崩吧", choreographer: "洛天依舞蹈工作室", duration: "3:10", difficulty: "初级", videoUrl: "/placeholder.svg?height=300&width=400", coverUrl: "/placeholder.svg?height=300&width=400", description: "轻松欢快的舞蹈,适合初学者,动作简单易学。", motionFile: "dalabengba_motion.fbx", category: "流行", tags: ["简单", "欢快", "流行"], createdAt: "2023-05-20T09:15:00Z", updatedAt: "2023-05-25T11:20:00Z", status: "已发布", activatedCount: 1356, printedCount: 2500, }, { id: "4", name: "普通DISCO", choreographer: "洛天依动作设计组", duration: "3:30", difficulty: "中等", videoUrl: "/placeholder.svg?height=300&width=400", coverUrl: "/placeholder.svg?height=300&width=400", description: "现代disco风格舞蹈,节奏感强,动作活力四射。", motionFile: "disco_motion.fbx", category: "现代", tags: ["活力", "现代", "disco"], createdAt: "2023-06-05T14:30:00Z", updatedAt: "2023-06-10T17:45:00Z", status: "已发布", activatedCount: 1578, printedCount: 3000, }, { id: "5", name: "华灯宴", choreographer: "古风舞蹈团队", duration: "4:50", difficulty: "高级", videoUrl: "/placeholder.svg?height=300&width=400", coverUrl: "/placeholder.svg?height=300&width=400", description: "古风舞蹈,动作优美细腻,需要较高的舞蹈技巧和表现力。", motionFile: "hualangyan_motion.fbx", category: "中国风", tags: ["古风", "优美", "高难度"], createdAt: "2023-07-12T11:20:00Z", updatedAt: "2023-07-18T13:40:00Z", status: "未发布", activatedCount: 0, printedCount: 2000, }, ] const dance = mockDances.find((dance) => dance.id === id) return dance || null } export default function DanceDetailPage() { const params = useParams() const router = useRouter() const { toast } = useToast() const [dance, setDance] = useState(null) const [isLoading, setIsLoading] = useState(true) const [isPlaying, setIsPlaying] = useState(false) const [isEditDialogOpen, setIsEditDialogOpen] = useState(false) const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false) const id = params.id as string useEffect(() => { const loadDance = async () => { setIsLoading(true) try { const data = await getDanceById(id) setDance(data) } catch (error) { toast({ title: "加载失败", description: "无法加载舞蹈详情,请重试。", variant: "destructive", }) } finally { setIsLoading(false) } } loadDance() }, [id, toast]) const handleEditDance = (updatedDance: Dance) => { setDance(updatedDance) toast({ title: "更新成功", description: `舞蹈 ${updatedDance.name} 已成功更新`, }) } const handleDeleteDance = async () => { // 模拟删除API await new Promise((resolve) => setTimeout(resolve, 500)) toast({ title: "删除成功", description: `舞蹈 ${dance?.name} 已成功删除`, variant: "destructive", }) // 返回舞蹈列表页 router.push("/dances") } const togglePlay = () => { setIsPlaying(!isPlaying) } if (isLoading) { return (
) } if (!dance) { return (

舞蹈不存在

找不到ID为 {id} 的舞蹈

) } const isPublished = dance.status === "已发布" return (
{!isPublished && ( )}
舞蹈详情 批次管理 数据分析
舞蹈预览
{dance.name}
{dance.status}
舞蹈详情

编舞者

{dance.choreographer}

分类

{dance.category}

时长

{dance.duration}

难度

{dance.difficulty}

激活数量

{dance.activatedCount}

印刷总数

{dance.printedCount}

剩余库存

{dance.printedCount - dance.activatedCount}

标签

{dance.tags?.map((tag, index) => ( {tag} ))}
{isPublished && (

该舞蹈已发布,基本属性不可修改。您仍可以增加印刷数量。

)}
舞蹈描述

{dance.description || "暂无描述"}

印刷批次 管理舞蹈卡牌的印刷批次和卡牌ID
{isPublished && ( )}
批次ID 创建日期 数量 起始ID 结束ID 操作
B001 2023-04-01 1000 DNC{dance.id}-0001 DNC{dance.id}-1000
B002 2023-08-15 1000 DNC{dance.id}-1001 DNC{dance.id}-2000
数据分析 查看舞蹈卡牌的激活数据和使用情况

激活数据图表

地区分布图表

时间趋势图表

{/* 编辑舞蹈对话框 */} {/* 删除确认对话框 */} ) }