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 0000000..945aa79 Binary files /dev/null and b/public/images/arrow.png differ