From 9ca0201da7d1edc70ddaf9769ea1dbd4dd39703f Mon Sep 17 00:00:00 2001 From: Baobhan Sith <80159437+Heavrnl@users.noreply.github.com> Date: Sun, 4 May 2025 10:39:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E7=BB=88=E7=AB=AF?= =?UTF-8?q?=E5=8F=B3=E9=94=AE=E7=B2=98=E8=B4=B4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Related to #11 --- packages/frontend/src/components/Terminal.vue | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/frontend/src/components/Terminal.vue b/packages/frontend/src/components/Terminal.vue index 4d97e41..6e81c1a 100644 --- a/packages/frontend/src/components/Terminal.vue +++ b/packages/frontend/src/components/Terminal.vue @@ -344,7 +344,25 @@ onMounted(() => { } }); } - // --- 结束添加复制粘贴 --- + + + // --- 添加右键粘贴功能 --- + if (terminalRef.value) { + terminalRef.value.addEventListener('contextmenu', async (event: MouseEvent) => { + event.preventDefault(); // 阻止默认右键菜单 + try { + const text = await navigator.clipboard.readText(); + if (text && terminal) { + // 将粘贴的文本发送到后端 + emit('data', text); + console.log('[Terminal] Pasted via Right Click'); + } + } catch (err) { + console.error('[Terminal] Failed to paste via Right Click:', err); + } + }); + } + // 重新添加鼠标滚轮缩放功能 if (terminalRef.value) { @@ -413,6 +431,10 @@ onBeforeUnmount(() => { if (selectionListenerDisposable) { selectionListenerDisposable.dispose(); } + + if (terminalRef.value) { + + } }); // 暴露 write 方法给父组件 (可选)