From f71205369aacbd55771e66782f18709d6929194c Mon Sep 17 00:00:00 2001 From: kjqwer <2990346238@qq.com> Date: Tue, 11 Nov 2025 15:21:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A4=8D=E5=88=B6=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/PresetDropdown.vue | 58 ++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 12 deletions(-) diff --git a/src/components/PresetDropdown.vue b/src/components/PresetDropdown.vue index 4364265..52e88d3 100644 --- a/src/components/PresetDropdown.vue +++ b/src/components/PresetDropdown.vue @@ -2,6 +2,7 @@ import { ref, computed, onMounted, onUnmounted } from 'vue'; import { usePromptStore } from '../stores/promptStore'; import type { PromptPreset } from '../types'; +import NotificationToast from './NotificationToast.vue'; const store = usePromptStore(); @@ -28,6 +29,20 @@ const showCreateForm = ref(false); const sortBy = ref<'name' | 'date'>('date'); const sortOrder = ref<'asc' | 'desc'>('desc'); +// 通知状态与方法(复用现有提示框架) +const notification = ref<{ message: string; type: 'success' | 'error' | 'info'; show: boolean }>({ + message: '', + type: 'info', + show: false +}); + +function showNotification(message: string, type: 'success' | 'error' | 'info' = 'info') { + notification.value = { message, type, show: true }; + setTimeout(() => { + notification.value.show = false; + }, 3000); +} + // 计算属性 const filteredPresets = computed(() => { const q = presetSearch.value.trim().toLowerCase(); @@ -196,18 +211,30 @@ function cancelRename() { renamingValue.value = ''; } -function duplicatePreset(preset: any) { - const newName = `${preset.name} - 副本`; +async function copyPresetToClipboard(preset: any) { + const text = preset?.text || ''; + if (!text) return; - // 只复制到扩展预设系统 - const defaultFolder = store.presetManagement?.settings?.defaultFolder; - store.createExtendedPreset({ - name: newName, - type: preset.type || 'positive', - content: preset.text, - description: preset.description || '复制的预设', - folderId: defaultFolder - }); + try { + await navigator.clipboard.writeText(text); + showNotification('已复制到剪贴板', 'success'); + } catch (err) { + try { + const ta = document.createElement('textarea'); + ta.value = text; + ta.style.position = 'fixed'; + ta.style.left = '-9999px'; + document.body.appendChild(ta); + ta.focus(); + ta.select(); + document.execCommand('copy'); + document.body.removeChild(ta); + showNotification('已复制到剪贴板', 'success'); + } catch (e) { + console.error('复制到剪贴板失败:', e); + showNotification('复制失败,请手动复制', 'error'); + } + } } function exportPreset(preset: any) { @@ -452,7 +479,7 @@ onUnmounted(() => {
-
+ + +