From 6b177c8ed91756ef5855cbe110380559f90f79ca Mon Sep 17 00:00:00 2001 From: yezian Date: Mon, 4 Nov 2024 17:01:21 +0800 Subject: [PATCH] =?UTF-8?q?ios=E7=9A=84=E5=AE=89=E8=A3=85=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E6=98=AF=E5=90=A6=E5=87=BA=E7=8E=B0=EF=BC=8C=E7=94=A8?= =?UTF-8?q?apollo=E8=BF=9B=E8=A1=8C=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/page.jsx | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/app/page.jsx b/app/page.jsx index 3e4e9ab..1c47a05 100644 --- a/app/page.jsx +++ b/app/page.jsx @@ -5,9 +5,13 @@ import InOtherApp from "@/components/InOtherApp"; import Footer from "@/components/Footer"; import IosInstallStepModal from "@/components/IosInstallStepModal/page"; import { getCookie } from "cookies-next"; +import baseRequest from "@/utils/baseRequest"; +import { generateSignature } from "@/utils/crypto"; export default function Home() { const [deviceType, setDeviceType] = useState(""); + const [isIosInstallButtonVisible, setIsIosInstallButtonVisible] = + useState(true); useEffect(() => { const userAgent = navigator.userAgent; //区分设备类型 @@ -18,6 +22,37 @@ export default function Home() { } else { setDeviceType("pc"); } + + const handleIosInstallButtonVisibility = async () => { + try { + const base = baseRequest(); + const body = { + ...base, + }; + const signature = generateSignature(body); + const _response = await fetch( + `/api/app/is_ios_install_button_visible?signature=${signature}`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(body), + } + ); + const _data = await _response.json(); + if (_data.ret === -1) { + Toast.show({ + content: _data.msg, + }); + return; + } + if (_data.data === 0) setIsIosInstallButtonVisible(false); + } catch (error) { + console.error(error); + } + }; + handleIosInstallButtonVisibility(); }, []); //ios安装教程Modal是否展示 @@ -155,7 +190,8 @@ export default function Home() { )}
- {deviceType !== "pc" && ( + {(deviceType === "Android" || + (deviceType === "ios" && isIosInstallButtonVisible)) && (
{ @@ -175,7 +211,11 @@ export default function Home() { )} {deviceType === "ios" && (
{ const inviter = getCookie("inviter"); const url = `https://app.tiefen.fun?inviter=${inviter}`;