"use client"; import React, { useState, useEffect } from "react"; import InOtherApp from "@/components/InOtherApp"; import baseRequest from "@/utils/baseRequest"; import { generateSignature } from "@/utils/crypto"; import { Toast } from "antd-mobile"; import copy from "@/utils/copy"; import IosInstallStepModal from "@/components/IosInstallStepModal/page"; export default function Download({ params }) { const [deviceType, setDeviceType] = useState(""); useEffect(() => { const userAgent = navigator.userAgent; //区分设备类型 if (/Android/i.test(userAgent)) { setDeviceType("Android"); } else if (/iPhone|iPad|iPod/i.test(userAgent)) { setDeviceType("ios"); } else { setDeviceType("pc"); } }, []); //点下载在剪贴板写入主播邀请信息 const copyInviter = () => { copy( `【${data?.name}】『ID:${data?.user_id}』,复制此条消息,打开铁粉空间APP,查看详情https://tiefen.fun/${data?.user_id}` ); }; //页面数据 const [data, setData] = useState({}); useEffect(() => { const getData = async () => { try { const base = baseRequest(); const signature = generateSignature({ user_id: parseInt(params.user_id, 10), ...base, }); const detailResponse = await fetch( `/api/streamer/list_ext_by_user_id?signature=${signature}`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ user_id: parseInt(params.user_id, 10), ...base, }), } ); const detailData = await detailResponse.json(); if (detailData.ret === -1) { Toast.show({ content: detailData.msg, }); return; } setData(detailData.data.streamer_ext); } catch (error) { console.error(error); } }; getData(); }, []); //ios安装教程Modal是否展示 const [isIosInstallStepModalVisible, setIsIosInstallStepModalVisible] = useState(false); return (
{deviceType === "pc" && (

立即下载

Android

扫描下方二维码

ios

)}
{deviceType === "pc" && (

手机扫码下载

)}
{deviceType !== "pc" && (
{ copyInviter(); if (deviceType === "ios") setIsIosInstallStepModalVisible(true); const url = deviceType === "ios" ? "itms-services://?action=download-manifest&url=https://filecdn01.tiefen.fun/appdownload/ironfans_beiyong.plist" : "https://filecdn01.tiefen.fun/appdownload/ironfans1.4.8.apk"; window.location.href = url; if (deviceType === "ios") { setIsIosInstallStepModalVisible(true); } }} > 安装
)}

{data?.name}   ID:{data?.user_id}

来「铁粉空间」查看我的更多精选内容

); }