"use client" import { useState } from "react" import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs" import { Textarea } from "@/components/ui/textarea" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" import { Badge } from "@/components/ui/badge" import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog" import { bookData } from "@/lib/book-data" import { FileText, BookOpen, Settings2, ChevronRight, CheckCircle, Edit3, Save, X, RefreshCw, Link2, } from "lucide-react" interface EditingSection { id: string title: string price: number content?: string } export default function ContentPage() { const [expandedParts, setExpandedParts] = useState(["part-1"]) const [editingSection, setEditingSection] = useState(null) const [isSyncing, setIsSyncing] = useState(false) const [feishuDocUrl, setFeishuDocUrl] = useState("") const [showFeishuModal, setShowFeishuModal] = useState(false) const togglePart = (partId: string) => { setExpandedParts((prev) => (prev.includes(partId) ? prev.filter((id) => id !== partId) : [...prev, partId])) } const totalSections = bookData.reduce( (sum, part) => sum + part.chapters.reduce((cSum, ch) => cSum + ch.sections.length, 0), 0, ) const handleEditSection = (section: { id: string; title: string; price: number }) => { setEditingSection({ id: section.id, title: section.title, price: section.price, content: "", }) } const handleSaveSection = () => { if (editingSection) { // 保存到本地存储或API console.log("[v0] Saving section:", editingSection) alert(`已保存章节: ${editingSection.title}`) setEditingSection(null) } } const handleSyncFeishu = async () => { if (!feishuDocUrl) { alert("请输入飞书文档链接") return } setIsSyncing(true) // 模拟同步过程 await new Promise((resolve) => setTimeout(resolve, 2000)) setIsSyncing(false) setShowFeishuModal(false) alert("飞书文档同步成功!") } return (

内容管理

共 {bookData.length} 篇 · {totalSections} 节内容

{/* 飞书同步弹窗 */} 同步飞书文档
setFeishuDocUrl(e.target.value)} />

请确保文档已开启公开访问权限

同步说明:系统将自动解析飞书文档结构,按照标题层级导入为章节内容。

{/* 章节编辑弹窗 */} setEditingSection(null)}> 编辑章节 {editingSection && (
setEditingSection({ ...editingSection, title: e.target.value })} />
setEditingSection({ ...editingSection, price: Number(e.target.value) })} />