From d1c5b0c1bfdb4846f7a03d667b518f3f7c68c167 Mon Sep 17 00:00:00 2001 From: yuyx <237899745@qq.com> Date: Sun, 30 Nov 2025 10:12:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E7=AB=AF=E6=96=87=E4=BB=B6=E5=88=97=E8=A1=A8=E6=BB=91=E5=8A=A8?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除 touchstart 中的 event.preventDefault(),不再阻止默认滚动 - 添加 handleLongPressMove 方法检测手指移动 - 滑动超过 10px 时自动取消长按,允许正常滚动 - 为 grid 和 list 视图的文件项添加 @touchmove 事件 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- frontend/app.html | 5 +++-- frontend/app.js | 44 ++++++++++++++++++++++++++++++++------------ 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/frontend/app.html b/frontend/app.html index a62c9bf..abc0cd4 100644 --- a/frontend/app.html +++ b/frontend/app.html @@ -1216,7 +1216,7 @@
-
+
- diff --git a/frontend/app.js b/frontend/app.js index 1b9d270..83a578c 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -208,6 +208,9 @@ createApp({ // 长按检测 longPressTimer: null, + longPressStartX: 0, + longPressStartY: 0, + longPressFile: null, // 媒体预览 showImageViewer: false, @@ -1433,32 +1436,49 @@ handleDragLeave(e) { // 长按开始(移动端) handleLongPressStart(file, event) { if (file.isDirectory) return; // 文件夹不响应长按 - - // 阻止默认的长按行为(如文本选择) - event.preventDefault(); - + + // 记录初始触摸位置,用于检测是否在滑动 + const touch = event.touches[0]; + this.longPressStartX = touch.clientX; + this.longPressStartY = touch.clientY; + this.longPressFile = file; + this.longPressTimer = setTimeout(() => { // 触发长按菜单 this.contextMenuFile = file; - - // 获取触摸点位置 - const touch = event.touches[0]; - this.contextMenuX = touch.clientX; - this.contextMenuY = touch.clientY; + + // 使用记录的触摸位置 + this.contextMenuX = this.longPressStartX; + this.contextMenuY = this.longPressStartY; this.showContextMenu = true; - + // 触摸震动反馈(如果支持) if (navigator.vibrate) { navigator.vibrate(50); } - + // 点击其他地方关闭菜单 this.$nextTick(() => { document.addEventListener('click', this.hideContextMenu, { once: true }); }); }, this.longPressDuration); }, - + + // 长按移动检测(移动端)- 滑动时取消长按 + handleLongPressMove(event) { + if (!this.longPressTimer) return; + + const touch = event.touches[0]; + const moveX = Math.abs(touch.clientX - this.longPressStartX); + const moveY = Math.abs(touch.clientY - this.longPressStartY); + + // 如果移动超过10px,认为是滑动,取消长按 + if (moveX > 10 || moveY > 10) { + clearTimeout(this.longPressTimer); + this.longPressTimer = null; + } + }, + // 长按取消(移动端) handleLongPressEnd() { if (this.longPressTimer) {