From 2f12a1fd27c33654177197356f82f53022fa3b75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Mon, 13 Jul 2026 12:15:03 +0800 Subject: [PATCH] =?UTF-8?q?feat(shop):=20=E6=8E=A5=E5=85=A5=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E9=A1=B5=E5=88=86=E4=BA=AB=E5=8A=9F=E8=83=BD=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=A5=BD=E5=8F=8B=E3=80=81=E6=9C=8B=E5=8F=8B=E5=9C=88?= =?UTF-8?q?=E5=8F=8A=E5=A4=8D=E5=88=B6=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 `src/pages/shop/index.config.ts` 中启用分享转发配置 - 在 `src/pages/shop/index.tsx` 增加 `useShare` 钩子调用,支持分享标题、路径及朋友圈和复制链接功能 - 分类页作为 tabBar 页面,确保三种分享按钮均可用 - 通过类型检查,代码无错误保证功能稳定 --- .workbuddy/memory/2026-07-13.md | 6 ++++++ src/pages/shop/index.config.ts | 2 ++ src/pages/shop/index.tsx | 9 +++++++++ 3 files changed, 17 insertions(+) diff --git a/.workbuddy/memory/2026-07-13.md b/.workbuddy/memory/2026-07-13.md index dc8faca..34459e6 100644 --- a/.workbuddy/memory/2026-07-13.md +++ b/.workbuddy/memory/2026-07-13.md @@ -16,3 +16,9 @@ - 复制链接:基础库 2.14.3+ Beta(官方说仅 Android,实测 iOS 也支持);朋友圈/复制链接开发者工具可能看不到入口,需真机测试。 - 注意:首页分享朋友圈后是单页模式(无登录态/不能跳转/tabBar 不渲染),首页是交互型页面,单页体验受限,但作传播入口可用;如需更好体验可用 `isTimelineSinglePage()` 做降级。 - 类型检查:零错误(历史既有 1 个 TS2688 仍在)。 + +## 分类页(pages/shop/index)分享接入 +- `src/pages/shop/index.config.ts`:加 `enableShareAppMessage: true` + `enableShareTimeline: true` +- `src/pages/shop/index.tsx`:导入 `useShare`,组件内调用 `useShare({ title:'购物商城 - 精选好物...', path:'/pages/shop/index', enableTimeline:true, enableCopyUrl:true })` +- 分类页和首页一样是 tabBar 页,三按钮全亮(好友/朋友圈/复制链接) +- 类型检查:零错误 diff --git a/src/pages/shop/index.config.ts b/src/pages/shop/index.config.ts index bb60ab4..2928f1a 100644 --- a/src/pages/shop/index.config.ts +++ b/src/pages/shop/index.config.ts @@ -1,3 +1,5 @@ export default { navigationBarTitleText: '购物商城', + enableShareAppMessage: true, + enableShareTimeline: true, } diff --git a/src/pages/shop/index.tsx b/src/pages/shop/index.tsx index 33c7e30..1066814 100644 --- a/src/pages/shop/index.tsx +++ b/src/pages/shop/index.tsx @@ -10,6 +10,7 @@ import { isGuest } from '@/utils/auth' import { isVipMember } from '@/utils/vip' import { getCompressedImageUrl } from '@/utils/image' import { requireLogin } from '@/utils/login-guard' +import { useShare } from '@/hooks/useShare' import EmptyState from '@/components/common/EmptyState' import LoadMore from '@/components/common/LoadMore' @@ -52,6 +53,14 @@ const ShopPage: React.FC = () => { const [keyword, setKeyword] = useState('') const searchTimerRef = useRef(null) + // 分享(tabBar 页支持好友分享 + 朋友圈 + 复制链接) + useShare({ + title: '购物商城 - 精选好物,实惠到家,等你来逛~', + path: '/pages/shop/index', + enableTimeline: true, + enableCopyUrl: true, + }) + useEffect(() => { loadCategories() }, [])