diff --git a/src/app/[lang]/poem/[id]/components/body.tsx b/src/app/[lang]/poem/[id]/components/body.tsx index c000d48b..1669ac04 100644 --- a/src/app/[lang]/poem/[id]/components/body.tsx +++ b/src/app/[lang]/poem/[id]/components/body.tsx @@ -1,7 +1,6 @@ import { type Author, type Poem } from "@prisma/client"; import { Verse } from "~/components/verse"; import { cn } from "~/utils"; -import CopyButton from "./copy"; import Link from "next/link"; import { type Locale, getLangUrl } from "~/dictionaries"; @@ -68,11 +67,6 @@ export const Body = (props: { /> ))} - - ); }; diff --git a/src/app/[lang]/poem/[id]/components/copy.tsx b/src/app/[lang]/poem/[id]/components/copy.tsx index 18dcfaa9..a9e70ed0 100644 --- a/src/app/[lang]/poem/[id]/components/copy.tsx +++ b/src/app/[lang]/poem/[id]/components/copy.tsx @@ -1,67 +1,67 @@ "use client"; import { type Poem, type Author } from "@prisma/client"; -import { Check, ClipboardCopy } from "lucide-react"; +import { ClipboardIcon } from "lucide-react"; +import { useState } from "react"; import { Button } from "~/components/ui/button"; -import { - Popover, - PopoverContent, - PopoverTrigger, -} from "~/components/ui/popover"; +import { type Locale } from "~/dictionaries"; import { MyHost, cn } from "~/utils"; interface Props { data: Poem & { author: Author }; className?: string; + lang: Locale; } const CopyButton = (props: Props) => { const { data: poem } = props; + const [copy, setCopy] = useState(false); + return ( - - - - - -
- - 已复制 -
-
-
+ setTimeout(() => { + setCopy(false); + }, 2000); + }} + > + + {copy ? "已复制" : "复制诗词译文"} + ); }; diff --git a/src/app/[lang]/poem/[id]/page.tsx b/src/app/[lang]/poem/[id]/page.tsx index dd8b1c01..3015486f 100644 --- a/src/app/[lang]/poem/[id]/page.tsx +++ b/src/app/[lang]/poem/[id]/page.tsx @@ -4,7 +4,7 @@ import { BookAIcon, ChevronRight, InfoIcon, - Printer, + PrinterIcon, TwitterIcon, } from "lucide-react"; import Link from "next/link"; @@ -30,6 +30,10 @@ const SaveShareButton = dynamic(() => import("./components/share"), { ssr: false, }); +const CopyButton = dynamic(() => import("./components/copy"), { + ssr: false, +}); + const DrawDefaultPreview = dynamic( () => import("./components/share/draw/default"), { ssr: false }, @@ -224,24 +228,25 @@ export default async function Page({ params, searchParams }: Props) { {dict.poem.tools} -
- +
+ {poem.content.split(/,|?|。|!/).length <= 9 && ( + + )} + + - @@ -249,7 +254,7 @@ export default async function Page({ params, searchParams }: Props) { scale={2} title={ <> - + 默认分享卡片 } @@ -257,12 +262,12 @@ export default async function Page({ params, searchParams }: Props) { - {poem.content.split(/,|?|。|!/).length === 5 && ( + {poem.content.split(/,|?|。|!/).length <= 5 && ( - + 适合绝句 }