feat(shop): 接入分类页分享功能支持好友、朋友圈及复制链接
- 在 `src/pages/shop/index.config.ts` 中启用分享转发配置 - 在 `src/pages/shop/index.tsx` 增加 `useShare` 钩子调用,支持分享标题、路径及朋友圈和复制链接功能 - 分类页作为 tabBar 页面,确保三种分享按钮均可用 - 通过类型检查,代码无错误保证功能稳定
This commit is contained in:
@@ -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 页,三按钮全亮(好友/朋友圈/复制链接)
|
||||
- 类型检查:零错误
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
export default {
|
||||
navigationBarTitleText: '购物商城',
|
||||
enableShareAppMessage: true,
|
||||
enableShareTimeline: true,
|
||||
}
|
||||
|
||||
@@ -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<any>(null)
|
||||
|
||||
// 分享(tabBar 页支持好友分享 + 朋友圈 + 复制链接)
|
||||
useShare({
|
||||
title: '购物商城 - 精选好物,实惠到家,等你来逛~',
|
||||
path: '/pages/shop/index',
|
||||
enableTimeline: true,
|
||||
enableCopyUrl: true,
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
loadCategories()
|
||||
}, [])
|
||||
|
||||
Reference in New Issue
Block a user