feat: 增强前端clipboard功能

This commit is contained in:
shaw
2025-12-27 15:16:52 +08:00
parent f1e47291cd
commit 016d7ef645
7 changed files with 73 additions and 52 deletions

View File

@@ -119,7 +119,7 @@
import { ref, computed, h, watch, type Component } from 'vue'
import { useI18n } from 'vue-i18n'
import Modal from '@/components/common/Modal.vue'
import { useAppStore } from '@/stores/app'
import { useClipboard } from '@/composables/useClipboard'
import type { GroupPlatform } from '@/types'
interface Props {
@@ -150,7 +150,7 @@ const props = defineProps<Props>()
const emit = defineEmits<Emits>()
const { t } = useI18n()
const appStore = useAppStore()
const { copyToClipboard: clipboardCopy } = useClipboard()
const copiedIndex = ref<number | null>(null)
const activeTab = ref<string>('unix')
@@ -340,14 +340,12 @@ ${key('requires_openai_auth')} ${operator('=')} ${keyword('true')}`
}
const copyContent = async (content: string, index: number) => {
try {
await navigator.clipboard.writeText(content)
const success = await clipboardCopy(content, t('keys.copied'))
if (success) {
copiedIndex.value = index
setTimeout(() => {
copiedIndex.value = null
}, 2000)
} catch (error) {
appStore.showError(t('common.copyFailed'))
}
}
</script>