完整性更新

现在已经实现了大部分基础功能
This commit is contained in:
SpecialX
2026-01-08 11:14:03 +08:00
parent 0da2eac0b4
commit 57807def37
155 changed files with 26421 additions and 1036 deletions

View File

@@ -0,0 +1,78 @@
import Link from "next/link"
import { notFound } from "next/navigation"
import { ArrowLeft, BookOpen, Inbox } from "lucide-react"
import { getTextbookById, getChaptersByTextbookId } from "@/modules/textbooks/data-access"
import { TextbookReader } from "@/modules/textbooks/components/textbook-reader"
import { Badge } from "@/shared/components/ui/badge"
import { Button } from "@/shared/components/ui/button"
import { EmptyState } from "@/shared/components/ui/empty-state"
import { getDemoStudentUser } from "@/modules/homework/data-access"
export const dynamic = "force-dynamic"
export default async function StudentTextbookDetailPage({
params,
}: {
params: Promise<{ id: string }>
}) {
const student = await getDemoStudentUser()
if (!student) {
return (
<div className="h-full flex-1 flex-col space-y-8 p-8 md:flex">
<div className="flex items-center justify-between space-y-2">
<div>
<h2 className="text-2xl font-bold tracking-tight">Textbook</h2>
<p className="text-muted-foreground">Read chapters and review content.</p>
</div>
</div>
<EmptyState title="No user found" description="Create a student user to read textbooks." icon={Inbox} />
</div>
)
}
const { id } = await params
const [textbook, chapters] = await Promise.all([getTextbookById(id), getChaptersByTextbookId(id)])
if (!textbook) notFound()
return (
<div className="flex h-[calc(100vh-4rem)] flex-col overflow-hidden">
<div className="flex items-center gap-4 border-b bg-background py-4 shrink-0 z-10">
<Button variant="ghost" size="icon" asChild>
<Link href="/student/learning/textbooks">
<ArrowLeft className="h-4 w-4" />
</Link>
</Button>
<div className="flex-1 min-w-0">
<div className="flex items-center gap-2 mb-1">
<Badge variant="outline">{textbook.subject}</Badge>
<span className="text-xs text-muted-foreground uppercase tracking-wider font-medium">
{textbook.grade ?? "-"}
</span>
</div>
<h1 className="text-xl font-bold tracking-tight line-clamp-1">{textbook.title}</h1>
</div>
</div>
<div className="flex-1 overflow-hidden pt-6">
{chapters.length === 0 ? (
<div className="px-8">
<EmptyState
icon={BookOpen}
title="No chapters"
description="This textbook has no chapters yet."
className="bg-card"
/>
</div>
) : (
<div className="h-[calc(100vh-140px)] px-8 min-h-0">
<TextbookReader chapters={chapters} />
</div>
)}
</div>
</div>
)
}