import { ArrowLeft, ArrowRight, BookOpen, Check, CheckCircle2, FileCheck, Flame, Info, Layers, Sparkles, Users, Video, Volume2, Wand2, X } from 'lucide-react' import { FormEvent, useEffect, useState } from 'react' import { Link, useNavigate } from 'react-router-dom' import { api } from '../api' import { COURSE_TEMPLATES, type CourseTemplate } from '../data/courseTemplates' const DEFAULT_COURSE_DESCRIPTION = `【课程简介】本课程围绕核心主题展开,通过清晰的知识讲解与案例说明,帮助学习者理解并掌握课程重点。 【制作要求】采用“讲师讲解 + PPT课件”的形式,画面简洁清晰,内容层次分明;讲解自然流畅,重点内容配合字幕或图示呈现;视频建议使用16:9横屏、1080P高清规格。` export function NewCourse() { const navigate = useNavigate() const [templates, setTemplates] = useState(COURSE_TEMPLATES) const [selectedTemplateId, setSelectedTemplateId] = useState(COURSE_TEMPLATES[0].id) const [activeTab, setActiveTab] = useState<'form' | 'templates'>('form') // 表单状态 const [name, setName] = useState('') const [category, setCategory] = useState('党政专题') const [description, setDescription] = useState(DEFAULT_COURSE_DESCRIPTION) const [busy, setBusy] = useState(false) const [error, setError] = useState('') const [filledNotice, setFilledNotice] = useState('') const [detailModalOpen, setDetailModalOpen] = useState(false) const currentTemplate = templates.find((t) => t.id === selectedTemplateId) || templates[0] useEffect(() => { api .getTemplates() .then((r) => { if (r.templates && r.templates.length > 0) { setTemplates(r.templates) } }) .catch(() => { // 使用默认本地配置 }) }, []) // 1. 一键填入表单 function handleFillTemplate(tmpl: CourseTemplate = currentTemplate) { setName(tmpl.name) setCategory(tmpl.category) setDescription(tmpl.description) setFilledNotice(`已填入示例《${tmpl.name}》内容,您可按需进行调整。`) setTimeout(() => setFilledNotice(''), 4500) } // 2. 一键以此模板创建完整项目 async function handleCreateFromTemplate(tmpl: CourseTemplate = currentTemplate) { setBusy(true) setError('') try { const { course } = await api.createFromTemplate(tmpl.id) navigate(`/courses/${course.id}`) } catch (x) { setError((x as Error).message) setBusy(false) } } // 3. 普通手动表单提交 async function submit(e: FormEvent) { e.preventDefault() setBusy(true) setError('') try { const { course } = await api.createCourse({ name: name.trim(), category, description: description.trim() }) navigate(`/courses/${course.id}`) } catch (x) { setError((x as Error).message) setBusy(false) } } return (
返回我的课程
{/* 左侧说明与精选示例区域 */} {/* 右侧表单区域 */}
{filledNotice && (
{filledNotice}
)}
COURSE PROFILE

课程基本信息