import { useEffect } from 'react';
import Taro, { useDidShow } from '@tarojs/taro';
import { type PageSharePayload } from '../lib/wechat-share';

/** 小程序：开启右上角分享菜单（不引入 H5 JSSDK） */
export default function WechatShareReady({ payload: _payload }: { payload?: PageSharePayload }) {
  useDidShow(() => {
    void Taro.showShareMenu({
      withShareTicket: true,
      showShareItems: ['shareAppMessage', 'shareTimeline'],
    }).catch(() => {
      void Taro.showShareMenu({ withShareTicket: true }).catch(() => {});
    });
  });

  useEffect(() => {
    /* weapp 无 JSSDK 入场 URL */
  }, []);

  return null;
}
