diff --git a/client/client.js b/client/client.js index d614db0..3763b8b 100644 --- a/client/client.js +++ b/client/client.js @@ -482,16 +482,16 @@ function startFileGuard(readFile) { }, 2600); }; const onClick = (event) => { + if (event.defaultPrevented) return; const target = event.target; if (target === null) return; const el = target.closest("button, a"); if (el === null) return; if (!looksLikeFilePath(el.textContent)) return; event.preventDefault(); - event.stopImmediatePropagation(); showToast(GUARD_MSG); }; - document.addEventListener("click", onClick, true); + document.addEventListener("click", onClick); const injectCopyButtons = () => { const links = document.querySelectorAll("button, a"); links.forEach((el) => { @@ -562,7 +562,7 @@ function startFileGuard(readFile) { }; const disconnectWs = hideWsEntries(); return () => { - document.removeEventListener("click", onClick, true); + document.removeEventListener("click", onClick); copyObserver.disconnect(); disconnectWs(); if (toastTimer !== null) window.clearTimeout(toastTimer); diff --git a/client/mobile/fileGuard.ts b/client/mobile/fileGuard.ts index dc2adbd..99e41b1 100644 --- a/client/mobile/fileGuard.ts +++ b/client/mobile/fileGuard.ts @@ -1,13 +1,17 @@ -// 移动端文件守卫(issue #17):dsh-web 在手机上点「文件链接」会触发桌面端 +// 移动端文件守卫(issue #17,issue #152 修正):dsh-web 在手机上点「文件链接」会触发桌面端 // workspaces.openPath(open ),既打不开(文件在电脑上),又会抛 // "path open failed". 这里做两件事: -// 1) 捕获阶段拦截这类激活(点击 / 键盘),改为弹一个提示; +// 1) 应用自己没处理这类激活时(点击 / 键盘)弹一个提示兜底; // 2) 在每个文件链接旁注入一个「复制」按钮,点它经主机 RPC 读文件正文再写剪贴板。 // 另外隐藏「添加工作区」入口(手机上配工作区无意义)。 // 移植自 dsh-web-mobile(MIT)。 // // 识别方式:不依赖 dsh-web 的 hash 类名(每次构建都变),只认「文本像文件路径的 //