"use client"; import React, { useState, useEffect } from "react"; import QRCode from "qrcode"; import { Toast, Image } from "antd-mobile"; import { useRouter, useParams } from "next/navigation"; import requireAPI from "@/utils/requireAPI"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faAngleLeft } from "@fortawesome/free-solid-svg-icons"; import { saveImage } from "@/utils/tools/handleFuns"; import clipboard from "copy-to-clipboard"; export default function Share() { //获取页面数据、生成二维码 const [data, setData] = useState({}); const [qrcodeUrl, setQrcodeUrl] = useState(""); const [isFetching, setIsFetching] = useState(true); const router = useRouter(); const { user_id } = useParams(); useEffect(() => { const getData = async () => { try { const data = await requireAPI( "POST", "/api/streamer/list_ext_by_user_id", { body: { user_id: parseInt(user_id, 10) }, } ); if (data.ret === -1) { Toast.show({ content: data.msg, }); return; } setData(data.data.streamer_ext); QRCode.toDataURL( `https://tiefen.fun/zone/${user_id}`, function (err, url) { setQrcodeUrl(url); } ); setIsFetching(false); } catch (error) { // console.error(error); } }; getData(); }, []); //分享海报组件 const Poster = () => { return (

{data?.name}

ID

{data?.user_id}

邀您加入我的 「铁粉空间」

铁粉空间
|官网:tiefen.fun
); }; //复制链接 const copyUrl = () => { clipboard(`https://tiefen.fun/zone/${user_id}`); Toast.show({ icon: "success", content: "已复制到剪贴板", position: "top", }); }; if (isFetching) { return (
); } return (
{ router.back(); }} />
{/* 内容 */}
); }