From 1bf06378dcfd23874f69f9a0a3135afffd92828b Mon Sep 17 00:00:00 2001 From: Minidoracat Date: Tue, 3 Jun 2025 17:19:52 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=BE=A9=20web=20ui=20?= =?UTF-8?q?=E5=89=AA=E8=B2=BC=E7=B0=BF=E9=87=8D=E8=A4=87=E8=B2=BC=E4=B8=8A?= =?UTF-8?q?=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/static/js/app.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/mcp_feedback_enhanced/web/static/js/app.js b/src/mcp_feedback_enhanced/web/static/js/app.js index e07b88d..8fd1f50 100644 --- a/src/mcp_feedback_enhanced/web/static/js/app.js +++ b/src/mcp_feedback_enhanced/web/static/js/app.js @@ -90,6 +90,7 @@ class FeedbackApp { this.images = []; // 初始化圖片陣列 this.isConnected = false; // 初始化連接狀態 this.websocket = null; // 初始化 WebSocket + this.isHandlingPaste = false; // 防止重複處理貼上事件的標記 // 立即檢查 DOM 狀態並初始化 if (document.readyState === 'loading') { @@ -461,8 +462,17 @@ class FeedbackApp { } handlePasteEvent(e) { + if (this.isHandlingPaste) { + console.log('Paste event already being handled, skipping subsequent call.'); + return; + } + this.isHandlingPaste = true; + const clipboardData = e.clipboardData || window.clipboardData; - if (!clipboardData) return; + if (!clipboardData) { + this.isHandlingPaste = false; + return; + } const items = clipboardData.items; let hasImages = false; @@ -472,12 +482,13 @@ class FeedbackApp { if (item.type.indexOf('image') !== -1) { hasImages = true; - e.preventDefault(); // 防止文字也被貼上 + e.preventDefault(); const file = item.getAsFile(); if (file) { console.log('從剪貼簿貼上圖片:', file.name, file.type); this.addImage(file); + break; } } } @@ -485,6 +496,10 @@ class FeedbackApp { if (hasImages) { console.log('已處理剪貼簿圖片'); } + + setTimeout(() => { + this.isHandlingPaste = false; + }, 50); } setLayoutMode(mode) {