From 31dd4ee2b21466073423c5d77f587e4d69de36e1 Mon Sep 17 00:00:00 2001 From: Julian Freeman Date: Wed, 25 Mar 2026 19:02:48 -0400 Subject: [PATCH] optimize copy feedback --- src/App.vue | 57 ++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/src/App.vue b/src/App.vue index c722486..c33c91a 100644 --- a/src/App.vue +++ b/src/App.vue @@ -88,14 +88,6 @@ const deleteHistoryItem = (id: string) => { } }; -const copyHistoryText = async (text: string) => { - try { - await navigator.clipboard.writeText(text); - } catch (err) { - console.error('Failed to copy history text: ', err); - } -}; - // Logs Management const selectedLogId = ref(null); const selectedLogItem = computed(() => @@ -116,6 +108,23 @@ const getLogSummary = (log: any) => { return 'JSON Data'; }; +// Universal Copy with Feedback +const activeCopyId = ref(null); + +const copyWithFeedback = async (text: string, id: string) => { + try { + await navigator.clipboard.writeText(text); + activeCopyId.value = id; + setTimeout(() => { + if (activeCopyId.value === id) { + activeCopyId.value = null; + } + }, 2000); + } catch (err) { + console.error('Failed to copy text: ', err); + } +}; + // Profile Management const newProfileName = ref(''); const isSavingProfile = ref(false); @@ -197,7 +206,6 @@ const sourceText = ref(''); const context = ref(''); const targetText = ref(''); const isTranslating = ref(false); -const showCopyFeedback = ref(false); interface Suggestion { id: number; @@ -287,18 +295,6 @@ const clearSource = () => { evaluationResult.value = null; }; -const copyTarget = async () => { - try { - await navigator.clipboard.writeText(targetText.value); - showCopyFeedback.value = true; - setTimeout(() => { - showCopyFeedback.value = false; - }, 2000); - } catch (err) { - console.error('Failed to copy text: ', err); - } -}; - const evaluateTranslation = async () => { if (!targetText.value) return; @@ -776,8 +772,8 @@ const translate = async () => {
-
@@ -1008,10 +1004,11 @@ const translate = async () => {

{{ selectedHistoryItem.sourceLang.displayName }} (原文)

@@ -1038,10 +1035,11 @@ const translate = async () => {

{{ selectedHistoryItem.targetLang.displayName }} (译文)

@@ -1385,10 +1383,11 @@ const translate = async () => { >{{ selectedLogItem.type === 'request' ? 'Request' : selectedLogItem.type === 'response' ? 'Response' : 'Error' }}