From c735a0aa1a4b626004087edf3e5095b442ee190a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=A8=E9=9C=96=E9=93=83?= Date: Wed, 27 May 2026 22:55:28 +0800 Subject: [PATCH] =?UTF-8?q?refactor(TextInputArea):=20=E5=A4=8D=E7=94=A8?= =?UTF-8?q?=20CopyButton=20=E7=BB=84=E4=BB=B6=E6=9B=BF=E6=8D=A2=E5=86=85?= =?UTF-8?q?=E8=81=94=E5=A4=8D=E5=88=B6=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/TextInputArea.tsx | 27 ++--- package-lock.json | 198 +++++++++++++++++++++++++---------- 2 files changed, 152 insertions(+), 73 deletions(-) diff --git a/components/TextInputArea.tsx b/components/TextInputArea.tsx index f0b32e3..a41c188 100644 --- a/components/TextInputArea.tsx +++ b/components/TextInputArea.tsx @@ -1,8 +1,9 @@ import React, { forwardRef, useCallback, useImperativeHandle, useRef, useState } from 'react'; -import { Copy, X } from 'lucide-react'; +import { X } from 'lucide-react'; import { useTranslation } from 'react-i18next'; import { cn } from '@/lib/utils'; import { toast } from 'sonner'; // 推荐使用 shadcn 的默认 Toast +import { CopyButton } from '@/components/CopyButton'; export type ValidateRule = { validator: (value: string) => boolean; @@ -187,16 +188,6 @@ const TextInputArea = forwardRef((props onClear?.(); }, [isControlled, onChange, onClear, t]); - const handleCopy = useCallback(async () => { - try { - await navigator.clipboard.writeText(value); - toast.success(t('messages.copySuccess')); - } catch { - setError(t('messages.copyError')); - toast.error(t('messages.copyError')); - } - }, [value, t]); - const handleAction = useCallback( (action: ToolbarAction) => { const isDisabled = @@ -284,14 +275,12 @@ const TextInputArea = forwardRef((props {/* 右侧系统按钮组 */}
{allowCopy && value && ( - + )} {showClear && value && !disabled && !readOnly && (