diff --git a/src/app/parent/dashboard.tsx b/src/app/parent/dashboard.tsx index e496c58..0704a08 100644 --- a/src/app/parent/dashboard.tsx +++ b/src/app/parent/dashboard.tsx @@ -9,6 +9,7 @@ import { ChildManage } from "./child-manage"; import { DevicesTab } from "./devices-tab"; import { OverviewTab } from "./overview-tab"; import { TemplatesTab } from "./templates-tab"; +import { PlayBtn } from "@/components/play-audio"; export type DayCell = { done: number; @@ -156,7 +157,7 @@ export function ParentDashboard({
{r.childName} {r.word} -
))} diff --git a/src/app/parent/overview-tab.tsx b/src/app/parent/overview-tab.tsx index b14d925..262798f 100644 --- a/src/app/parent/overview-tab.tsx +++ b/src/app/parent/overview-tab.tsx @@ -4,6 +4,7 @@ import { useState } from "react"; import { cn } from "@/lib/utils"; import { addDays, dowOf, todayStr } from "@/lib/dates"; import { subjectMeta } from "@/lib/subjects"; +import { PlayBtn } from "@/components/play-audio"; import { Button } from "@/components/ui/button"; import type { OverviewData } from "./dashboard"; @@ -160,7 +161,7 @@ export function OverviewTab({ data }: { data: OverviewData }) { {cell.recs.map((r, i) => (
{r.word} -
))} diff --git a/src/components/play-audio.tsx b/src/components/play-audio.tsx new file mode 100644 index 0000000..4653c3e --- /dev/null +++ b/src/components/play-audio.tsx @@ -0,0 +1,31 @@ +"use client"; + +import { useState } from "react"; +import { Volume2 } from "lucide-react"; +import { cn } from "@/lib/utils"; + +// 单个播放按钮:点击播放音频,不显示进度条(与单词读音一致) +export function PlayBtn({ src, className }: { src: string; className?: string }) { + const [playing, setPlaying] = useState(false); + const play = () => { + const a = new Audio(src); + a.onended = () => setPlaying(false); + a.onerror = () => setPlaying(false); + setPlaying(true); + a.play(); + }; + return ( + + ); +}