feat(miniprogram): 文章分享功能 onShareAppMessage
- 文章详情页注册微信分享(分享标题 + 路径带 article id) - 分享时触发 article_share 埋点事件
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { View, Text, RichText } from '@tarojs/components';
|
||||
import Taro, { useRouter } from '@tarojs/taro';
|
||||
import Taro, { useRouter, useShareAppMessage } from '@tarojs/taro';
|
||||
import { getArticleDetail, Article } from '../../../services/article';
|
||||
import { trackEvent } from '@/services/analytics';
|
||||
import './index.scss';
|
||||
|
||||
export default function ArticleDetail() {
|
||||
@@ -11,6 +12,14 @@ export default function ArticleDetail() {
|
||||
const [article, setArticle] = useState<Article | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useShareAppMessage(() => {
|
||||
trackEvent('article_share', { article_id: id });
|
||||
return {
|
||||
title: article?.title || '健康资讯',
|
||||
path: `/pages/article/detail/index?id=${id}`,
|
||||
};
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!id) return;
|
||||
setLoading(true);
|
||||
|
||||
Reference in New Issue
Block a user