11'use client'
22
33import * as React from 'react'
4- import { ReactNode } from 'react'
54import { ModelIcon } from '@lobehub/icons'
6- import { useClipboard } from '@mantine/hooks'
75import { useQuery } from '@tanstack/react-query'
8- import { AlertCircleIcon , CheckCircle2Icon , CheckIcon , CopyIcon } from 'lucide-react'
9- import { toast } from 'sonner'
6+ import { AlertCircleIcon , CheckCircle2Icon , CheckIcon } from 'lucide-react'
107import { match } from 'ts-pattern'
118
129import { isCompleted , useProgress } from '@/lib/progress/utils'
13- import { cn } from '@/lib/utils'
1410import { AppCardSection } from '@/components/app/app-card'
1511import { Callout } from '@/components/base/callout'
1612import { Button } from '@/components/ui/button'
1713import { Skeleton } from '@/components/ui/skeleton'
1814import { Spinner } from '@/components/ui/spinner'
15+ import { TextCopyButton } from '@/app/(model)/text-copy-button'
1916import { useModelStore } from '@/stores/model-store-provider'
2017import { useTRPC } from '@/trpc/client'
2118
@@ -131,17 +128,9 @@ function HostStatusCard({ hostId }: { hostId: string }) {
131128 < dl className = "contents" >
132129 < dt className = "text-muted-foreground" > API 端点</ dt >
133130 < dd >
134- < CopyButton value = { url } message = "已复制 API 端点" >
131+ < TextCopyButton value = { url } message = "已复制 API 端点" >
135132 { url }
136- </ CopyButton >
137- </ dd >
138- </ dl >
139- < dl className = "contents" >
140- < dt className = "text-muted-foreground" > API 密钥</ dt >
141- < dd >
142- < CopyButton value = { deployment . apiKey } message = "已复制 API 密钥" >
143- { deployment . apiKey }
144- </ CopyButton >
133+ </ TextCopyButton >
145134 </ dd >
146135 </ dl >
147136 </ div >
@@ -158,25 +147,3 @@ function DeploySuccessCallout() {
158147 </ Callout >
159148 )
160149}
161-
162- function CopyButton ( { value, message, children } : { value : string ; message : string ; children ?: ReactNode } ) {
163- const { copy, copied, error } = useClipboard ( )
164-
165- return (
166- < button
167- className = { cn (
168- '[&>svg]:text-primary hover:[&_svg]:text-primary/80 hover:text-foreground/90 inline-flex items-center gap-2 [&>svg]:size-3.5' ,
169- error && '[&>svg]:text-destructive' ,
170- copied && '[&>svg]:text-success' ,
171- ) }
172- onClick = { ( ) => {
173- copy ( value )
174- toast . success ( message )
175- } }
176- >
177- { children }
178- { copied ? < CheckIcon /> : error ? < AlertCircleIcon /> : < CopyIcon /> }
179- < span className = "sr-only" > 复制</ span >
180- </ button >
181- )
182- }
0 commit comments