From 64f97e6c1778d955eb5533b55c3da537bf4042cf Mon Sep 17 00:00:00 2001 From: yezian Date: Fri, 6 Sep 2024 10:34:44 +0300 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9C=A8webview=E6=89=93?= =?UTF-8?q?=E5=BC=80=E6=97=B6=EF=BC=8C=E2=80=9C=E5=89=8D=E5=BE=80=E6=B5=8F?= =?UTF-8?q?=E8=A7=88=E5=99=A8=E6=89=93=E5=BC=80=E2=80=9D=E7=9A=84=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/layout.js | 3 +++ components/InOtherApp/index.js | 39 +++++++++++++++++++++++++++++++++ public/images/arrow.png | Bin 0 -> 1039 bytes 3 files changed, 42 insertions(+) create mode 100644 components/InOtherApp/index.js create mode 100644 public/images/arrow.png diff --git a/app/layout.js b/app/layout.js index 6476f61..9aa6b36 100644 --- a/app/layout.js +++ b/app/layout.js @@ -7,6 +7,8 @@ import BottomNav from "../components/BottomNav"; import { Provider } from "react-redux"; import store from "../store"; import withAuth from "@/components/WithAuth"; +import InOtherApp from "@/components/InOtherApp"; + const inter = Inter({ subsets: ["latin"] }); const metadata = { @@ -229,6 +231,7 @@ export default function RootLayout({ children }) {
+ {withAuth(
diff --git a/components/InOtherApp/index.js b/components/InOtherApp/index.js new file mode 100644 index 0000000..8851625 --- /dev/null +++ b/components/InOtherApp/index.js @@ -0,0 +1,39 @@ +"use client"; + +import React, { useState, useEffect } from "react"; + +export default function InOtherApp() { + //区分是否在微信/微博/qq/支付宝/钉钉内置浏览器中打开 + const [isInOtherApp, setIsInOtherApp] = useState(false); + useEffect(() => { + const userAgent = navigator.userAgent.toLowerCase(); + let temIsInOtherApp = + userAgent.match(/MicroMessenger/i) == "micromessenger" || + userAgent.match(/WeiBo/i) == "weibo" || + (userAgent.indexOf("qq") !== -1 && + userAgent.indexOf("mqqbrowser") === -1) || + /alipay/gi.test(userAgent) || + userAgent.indexOf("dingtalk") !== -1; + if (temIsInOtherApp) { + setIsInOtherApp(true); + } + }, []); + + if (!isInOtherApp) { + return null; + } + + return ( +
+
+ +
+

+ 请前往浏览器打开 +

+
+ ); +} diff --git a/public/images/arrow.png b/public/images/arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..945aa79a7924c9f208244ae799175297062550ce GIT binary patch literal 1039 zcmeAS@N?(olHy`uVBq!ia0vp^+kp5i2Q!dVI$dP~q|5?*LR^9Lf6~FniGr#x0 zG27i2VxIf>-kSoen($0@@fJ&&4ZWf=#|wdI&V6>>(uECfm(3+~@`V0&v#2P&J}6V5 zam&-P!C}$+2qreemz@#<5nGyrr>gvN;l4Jr&7omc(MA822aUF5vM<+qz9jzOL9NP* z`5Fh+)Ek%l{h{#J-pqZ~I0=Jwm&3qg7)KkGJdCDrqHEFAj zmIbeR|0X#j*KPHt7YX*i9tL)a+*=`5ohtUW;ClWg>)ZSDbJ(h%PAHYqI`M1z?T_NK zSD#uqVUn}@yu&JHW(Uv3%4fg$V)Vv7#kakeU0A?ArCM)$w0~az?MYtW-c>axs=R&4 ze(S}Dw;D&)(|@}NZQ1N|kZt2sGuzuAvo`DQOEOEptS?!6u}h`yMw8ChPudgK-Yc5Q z`Q+J&$y?r5eBn><_`Nv!7jyD9le(Dn_A4I8awZBdb6d4UT)Jp2=8tCBix0^-8JOkrkQEJ+lNC_i-A&YOAn`lMfNT zRC8CiW#YQj4$%+0HqJk(>cDULDe23S`PsH=ijgPgFr?bD1U06}{!|oL@|&xhY1h|X zFAws%E9}%ruztVlnykjvZl-IGEbIdd&dg#7xLO(Lz?>N?-}8Az;ScviGrui*(JZ@6 zB$Gwg;Mamx6=8qvUNk+D-!;m34jCbWZgk>s