diff --git a/app/apple-icon.png b/app/apple-icon.png deleted file mode 100644 index a373fd1..0000000 Binary files a/app/apple-icon.png and /dev/null differ diff --git a/app/courses/page.tsx b/app/courses/page.tsx new file mode 100644 index 0000000..ca98c4f --- /dev/null +++ b/app/courses/page.tsx @@ -0,0 +1,357 @@ +'use client'; + +import Link from 'next/link'; +import { useRef, useState } from 'react'; +import { useRouter } from 'next/navigation'; +import { + ArrowLeft, + ArrowRight, + BookOpen, + Check, + Clock, + FileText, + Loader2, + Search, +} from 'lucide-react'; +import { toast } from 'sonner'; +import { BrandLogo } from '@/components/brand-logo'; +import { Button } from '@/components/ui/button'; +import { chapters, courses, searchChapters, type MarketCourse } from '@/lib/course-market/catalog'; +import { useImportClassroom } from '@/lib/import/use-import-classroom'; +import { loadStageData } from '@/lib/utils/stage-storage'; + +const domains = [...new Set(chapters.map((chapter) => chapter.domain))]; +const courseKey = (course: MarketCourse) => `course-market:${course.id}:v${course.version}`; + +export default function CourseMarketPage() { + const router = useRouter(); + const [query, setQuery] = useState(''); + const [domain, setDomain] = useState(''); + const [publishedOnly, setPublishedOnly] = useState(false); + const [chapterId, setChapterId] = useState(''); + const [opening, setOpening] = useState(null); + const pendingCourse = useRef(null); + const busy = useRef(false); + const { importFile } = useImportClassroom((stageId) => { + if (pendingCourse.current) { + try { + localStorage.setItem(courseKey(pendingCourse.current), stageId); + } catch { + /* Course is already saved. */ + } + } + router.push(`/classroom/${stageId}`); + }); + + const filtered = searchChapters(query, domain, publishedOnly); + const visible = chapterId ? filtered.filter((chapter) => chapter.id === chapterId) : filtered; + const reset = () => { + setQuery(''); + setDomain(''); + setPublishedOnly(false); + setChapterId(''); + }; + + async function openCourse(course: MarketCourse) { + if (busy.current) return; + busy.current = true; + setOpening(course.id); + pendingCourse.current = course; + try { + let savedId: string | null = null; + try { + savedId = localStorage.getItem(courseKey(course)); + } catch { + /* Continue with import. */ + } + if (savedId && (await loadStageData(savedId))) { + router.push(`/classroom/${savedId}`); + return; + } + const response = await fetch(course.packageUrl); + if (!response.ok) throw new Error('课程包暂时无法下载,请稍后重试。'); + await importFile( + new File([await response.blob()], `${course.id}.maic.zip`, { type: 'application/zip' }), + ); + } catch (error) { + toast.error(error instanceof Error ? error.message : '打开课程失败,请重试。'); + } finally { + busy.current = false; + pendingCourse.current = null; + setOpening(null); + } + } + + return ( +
+
+
+ + + + + + 返回首页 + +
+
+
+
+
+

+ RDK LEARNING +

+

课程市场

+

+ 从第一块开发板开始,逐章建立你的工程知识。选择章节,查看知识点,进入课程学习。 +

+ +
+
+
+ {chapters.length} + 学习章节 +
+
+ {courses.length} + 已上线课程 +
+
+ 260 + 细分小节 +
+
+
+
+
+ + { + setQuery(event.target.value); + setChapterId(''); + }} + placeholder="搜索章节、课程或知识点,如 RDK、Python、串口" + className="h-10 w-full rounded-md border border-input bg-background pr-3 pl-9 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring" + /> +
+ + +
+
+ +
+
+

+ {visible.length} 个章节 ·{' '} + { + courses.filter((course) => + visible.some((chapter) => chapter.id === course.chapterId), + ).length + }{' '} + 门可学课程 +

+ +
+ {visible.length === 0 && ( +
+ +

没有找到匹配的章节

+

+ 试试更短的关键词,或清除筛选条件。 +

+ +
+ )} +
+ {visible.map((chapter) => { + const chapterCourses = courses.filter((course) => course.chapterId === chapter.id); + return ( +
+
+
+ + CHAPTER {chapter.id} + + + {chapter.domain} + + {chapter.level} +
+

{chapter.title}

+

+ {chapter.sections.length} 小节 ·{' '} + {chapter.sections.reduce((sum, section) => sum + section.points.length, 0)}{' '} + 个知识点 · 建议先修: + {chapter.prerequisites.length + ? chapter.prerequisites.map((id) => `第 ${id} 章`).join('、') + : '无需先修'} +

+
+ + 查看小节与知识点 + +
+ {chapter.sections.map((section) => ( +
+

+ {section.id} {section.title} +

+
    + {section.points.map((point) => ( +
  • {point.title}
  • + ))} +
+
+ ))} +
+
+
+
+ {chapterCourses.length ? ( + chapterCourses.map((course) => ( +
+
+

+ 平台精选 · 已上线 +

+

{course.title}

+

+ {course.description} +

+
+ + + {course.duration} + + + + {course.pages} 页 · 含测验 + +
+
+ +
+ )) + ) : ( +
+ + 本章课程正在规划,知识大纲可先行查看。 + + + 待上线 + +
+ )} +
+
+ ); + })} +
+
+
+
+
+ ); +} diff --git a/app/favicon.ico b/app/favicon.ico deleted file mode 100644 index 615f780..0000000 Binary files a/app/favicon.ico and /dev/null differ diff --git a/app/generation-preview/page.tsx b/app/generation-preview/page.tsx index f2acc52..0554406 100644 --- a/app/generation-preview/page.tsx +++ b/app/generation-preview/page.tsx @@ -1191,7 +1191,7 @@ function GenerationPreviewContent() { // Still loading session from sessionStorage if (!sessionLoaded) { return ( -
+
@@ -1202,7 +1202,7 @@ function GenerationPreviewContent() { // No session found if (!session) { return ( -
+
@@ -1234,7 +1234,7 @@ function GenerationPreviewContent() { const editorOutlines = session.sceneOutlines ?? streamingOutlines ?? []; return ( -
+
+
{/* Background Decor */}
@@ -1335,7 +1335,7 @@ function GenerationPreviewContent() { transition={{ duration: 0.5 }} className="w-full" > - + {/* Progress Dots */}
{activeSteps.map((step, idx) => ( @@ -1510,7 +1510,7 @@ function GenerationPreviewContent() { {generatedAgents.length > 0 && !showAgentReveal && ( {themeOpen && ( -
+
-
+
{/* Settings Button */}
@@ -811,18 +825,6 @@ function HomePage() { initialSection={settingsSection} /> - {/* ═══ Background Decor ═══ */} -
-
-
-
- {/* ═══ Hero section: title + input (centered, wider) ═══ */} {/* ── Logo ── */}
- + className="mb-2" + > + + {workbenchEntryEnabled ? (
{t('home.slogan')} @@ -874,7 +876,7 @@ function HomePage() { >
{/* ── Greeting + Profile + Agents ── */}
@@ -888,7 +890,7 @@ function HomePage() {