From 6710fd8c4fcb0aa6bff558cd31026f75ff02c43b Mon Sep 17 00:00:00 2001 From: yezian Date: Fri, 13 Dec 2024 13:14:44 +0800 Subject: [PATCH] =?UTF-8?q?ios=E7=89=88=E6=9C=AC=E8=8B=A5=E5=A4=A7?= =?UTF-8?q?=E4=BA=8E17=E5=88=99=E4=B8=8D=E5=B1=95=E7=A4=BA=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/page.jsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/page.jsx b/app/page.jsx index af07e33..16265d1 100644 --- a/app/page.jsx +++ b/app/page.jsx @@ -11,14 +11,25 @@ import { generateSignature } from "@/utils/crypto"; export default function Home() { const [deviceType, setDeviceType] = useState(""); const [installInfo, setInstallInfo] = useState({}); + const [isIosVersionGreaterThan17, setIsIosVersionGreaterThan17] = + useState(false); useEffect(() => { const userAgent = navigator.userAgent; + console.log(userAgent); //区分设备类型 if (/Android/i.test(userAgent)) { setDeviceType("Android"); } else if (/iPhone|iPad|iPod/i.test(userAgent)) { setDeviceType("ios"); + //区分ios版本号是否小于18,小于18则不展示下载按钮 + const version = userAgent + .toLowerCase() + .match(/cpu iphone os (.*?) like mac os/); + if (version) { + const mainVersion = parseInt(version[1].split("_")[0], 10); + mainVersion > 17 && setIsIosVersionGreaterThan17(true); + } } else { setDeviceType("pc"); } @@ -204,7 +215,8 @@ export default function Home() { )} {(deviceType === "Android" || (deviceType === "ios" && - installInfo?.is_ios_install_button_visible === 1)) && ( + installInfo?.is_ios_install_button_visible === 1 && + !isIosVersionGreaterThan17)) && (