feat(miniprogram): 文章分享功能 onShareAppMessage
Some checks failed
CI / rust-check (push) Has been cancelled
CI / rust-test (push) Has been cancelled
CI / frontend-build (push) Has been cancelled
CI / security-audit (push) Has been cancelled

- 文章详情页注册微信分享(分享标题 + 路径带 article id)
- 分享时触发 article_share 埋点事件
This commit is contained in:
iven
2026-04-24 13:03:02 +08:00
parent 030afb8213
commit b4e8399194

View File

@@ -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);