From c3fad3da13956a8ac6314b36a44dac5992ab7c33 Mon Sep 17 00:00:00 2001 From: zzlgreat Date: Tue, 6 Jan 2026 18:47:23 +0800 Subject: [PATCH] =?UTF-8?q?community=E5=A2=9E=E5=8A=A0=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ShareButton/index.js | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/components/ShareButton/index.js b/src/components/ShareButton/index.js index 19ca7b54..1df43504 100644 --- a/src/components/ShareButton/index.js +++ b/src/components/ShareButton/index.js @@ -100,24 +100,13 @@ const ShareButton = ({ // 点击分享按钮 const handleShareClick = useCallback(() => { - if (isInWechat) { - // 在微信中,打开分享引导弹窗 - onOpen(); - } else if (navigator.share) { - // 支持 Web Share API - navigator.share({ - title: title || document.title, - text: desc, - url: link || window.location.href, - }).catch(() => { - // 用户取消或失败,打开弹窗作为降级 - onOpen(); - }); - } else { - // 不支持 Web Share API,打开弹窗 - onOpen(); - } - }, [isInWechat, title, desc, link, onOpen]); + // 统一打开分享弹窗,提供复制链接功能 + // 原因: + // 1. 微信内:需要引导用户点击右上角分享 + // 2. 微信外:navigator.share 无法分享到微信,复制链接更实用 + // 3. PC端:直接复制链接是最可靠的方式 + onOpen(); + }, [onOpen]); // 渲染按钮 const renderButton = () => {