feat: enhance textbook reader with anchor text support and improve knowledge point management
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
import Link from "next/link"
|
||||
import { notFound } from "next/navigation"
|
||||
|
||||
import { ArrowLeft, BookOpen, Inbox } from "lucide-react"
|
||||
import { BookOpen, Inbox } from "lucide-react"
|
||||
|
||||
import { getTextbookById, getChaptersByTextbookId } from "@/modules/textbooks/data-access"
|
||||
import { getTextbookById, getChaptersByTextbookId, getKnowledgePointsByTextbookId } 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"
|
||||
|
||||
@@ -34,29 +33,25 @@ export default async function StudentTextbookDetailPage({
|
||||
|
||||
const { id } = await params
|
||||
|
||||
const [textbook, chapters] = await Promise.all([getTextbookById(id), getChaptersByTextbookId(id)])
|
||||
const [textbook, chapters, knowledgePoints] = await Promise.all([
|
||||
getTextbookById(id),
|
||||
getChaptersByTextbookId(id),
|
||||
getKnowledgePointsByTextbookId(id)
|
||||
])
|
||||
|
||||
if (!textbook) notFound()
|
||||
|
||||
return (
|
||||
<div className="flex h-[calc(100vh-4rem)] flex-col overflow-hidden bg-muted/5">
|
||||
<div className="flex items-center gap-4 border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60 py-3 px-6 shrink-0 z-10">
|
||||
<Button variant="ghost" size="sm" className="gap-2 text-muted-foreground hover:text-foreground" asChild>
|
||||
<Link href="/student/learning/textbooks">
|
||||
<ArrowLeft className="h-4 w-4" />
|
||||
Back
|
||||
</Link>
|
||||
</Button>
|
||||
<div className="w-px h-8 bg-border mx-2" />
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-center gap-2">
|
||||
<h1 className="text-lg font-bold tracking-tight truncate mr-2">{textbook.title}</h1>
|
||||
<Badge variant="secondary" className="font-normal text-xs">{textbook.subject}</Badge>
|
||||
{textbook.grade && (
|
||||
<span className="text-xs text-muted-foreground border px-1.5 py-0.5 rounded">
|
||||
{textbook.grade}
|
||||
</span>
|
||||
)}
|
||||
<div className="flex items-center justify-between border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60 py-3 px-6 shrink-0 z-10">
|
||||
<div className="flex items-center gap-3 min-w-0">
|
||||
<h1 className="text-lg font-bold tracking-tight truncate">{textbook.title}</h1>
|
||||
<div className="flex items-center gap-2 text-sm text-muted-foreground">
|
||||
<span className="hidden sm:inline-block w-px h-4 bg-border" />
|
||||
<Badge variant="outline" className="font-normal text-xs">{textbook.subject}</Badge>
|
||||
{textbook.grade && (
|
||||
<Badge variant="secondary" className="font-normal text-xs">{textbook.grade}</Badge>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -73,7 +68,7 @@ export default async function StudentTextbookDetailPage({
|
||||
</div>
|
||||
) : (
|
||||
<div className="h-full min-h-0 max-w-[1600px] mx-auto w-full">
|
||||
<TextbookReader chapters={chapters} />
|
||||
<TextbookReader chapters={chapters} knowledgePoints={knowledgePoints} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user