From 6a40f0a1298f3786bb90c0610ab3ce8bd9eb5520 Mon Sep 17 00:00:00 2001 From: meetqy Date: Sun, 10 Mar 2024 13:50:44 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=A4=8D=E5=88=B6?= =?UTF-8?q?=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/[lang]/poem/[id]/components/body.tsx | 6 -- src/app/[lang]/poem/[id]/components/copy.tsx | 92 ++++++++++---------- src/app/[lang]/poem/[id]/page.tsx | 39 +++++---- 3 files changed, 68 insertions(+), 69 deletions(-) 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..00bb8436 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 { 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 && ( - + 适合绝句 } From 8628bcc4c33a9ae044c7d37cbad3866308205484 Mon Sep 17 00:00:00 2001 From: meetqy Date: Sun, 10 Mar 2024 13:50:59 +0800 Subject: [PATCH 2/2] type --- src/app/[lang]/poem/[id]/components/copy.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/[lang]/poem/[id]/components/copy.tsx b/src/app/[lang]/poem/[id]/components/copy.tsx index 00bb8436..a9e70ed0 100644 --- a/src/app/[lang]/poem/[id]/components/copy.tsx +++ b/src/app/[lang]/poem/[id]/components/copy.tsx @@ -4,7 +4,7 @@ import { type Poem, type Author } from "@prisma/client"; import { ClipboardIcon } from "lucide-react"; import { useState } from "react"; import { Button } from "~/components/ui/button"; -import { Locale } from "~/dictionaries"; +import { type Locale } from "~/dictionaries"; import { MyHost, cn } from "~/utils"; interface Props {