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 方法给父组件 (可选)