|
@@ -6,15 +6,16 @@ import ptBR from "antd-mobile/es/locales/pt-BR";
|
|
|
import { ThemeProviderProps } from "next-themes/dist/types";
|
|
|
import { ReactNode, useEffect, useState } from "react";
|
|
|
|
|
|
+import { usePathname } from "@/i18n/routing";
|
|
|
import { server } from "@/utils/client";
|
|
|
import { useDebounceEffect, useRequest } from "ahooks";
|
|
|
import clsx from "clsx";
|
|
|
import { initializeApp } from "firebase/app";
|
|
|
import { getMessaging, getToken, onMessage } from "firebase/messaging";
|
|
|
-import { usePathname, useSearchParams } from "next/navigation";
|
|
|
+import { useSearchParams } from "next/navigation";
|
|
|
import Script from "next/script";
|
|
|
|
|
|
-import { setupFontSize } from "@/utils";
|
|
|
+import { commonMask, setupFontSize } from "@/utils";
|
|
|
import { Local } from "@/utils/storage";
|
|
|
import { motion } from "framer-motion";
|
|
|
|
|
@@ -23,18 +24,30 @@ import { useActivityStore } from "@/stores/useActivityStore";
|
|
|
import { useGlobalNoticeStore } from "@/stores/useGlobalNoticeStore";
|
|
|
import { getToken as getUserToken } from "@/utils/Cookies";
|
|
|
|
|
|
-import Agent, { AgentSuffix } from "@/components/Agent";
|
|
|
+import { PromotionRep } from "@/api/home";
|
|
|
import feedback from "@/feedback";
|
|
|
+import doAutoDialog from "@/feedback/auto";
|
|
|
import { PollingState, usePollingStore } from "@/stores/usePollingStore";
|
|
|
import { useSuspensionStore } from "@/stores/useSuspensionStore";
|
|
|
import { useUserInfoStore } from "@/stores/useUserInfoStore";
|
|
|
import { useVipStore } from "@/stores/useVipStore";
|
|
|
import { useWalletStore } from "@/stores/useWalletStore";
|
|
|
-
|
|
|
export interface ProvidersProps {
|
|
|
children: ReactNode;
|
|
|
themeProps?: Omit<ThemeProviderProps, "children">;
|
|
|
}
|
|
|
+
|
|
|
+const getPromotions = async () => {
|
|
|
+ return server
|
|
|
+ .request<PromotionRep[], { summery: { showType: 1 | 2 } }>({
|
|
|
+ url: "/v1/api/front/pop_list",
|
|
|
+ method: "POST",
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ if (res.code === 200) return res;
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
// 初始化 fireBase
|
|
|
const initFirebase = () => {
|
|
|
// 是否是https
|
|
@@ -352,31 +365,55 @@ export default function SidebarLayout({ children, themeProps }: ProvidersProps)
|
|
|
isCollapse: state.isCollapse,
|
|
|
setCollapse: state.setCollapse,
|
|
|
}));
|
|
|
+ const [popData, setPopData] = useState<PromotionRep[]>([]);
|
|
|
const pathname = usePathname();
|
|
|
-
|
|
|
useEffect(() => {
|
|
|
- const local = pathname.split("/")[1];
|
|
|
- doShowProxyCheck();
|
|
|
+ if (feedback.hasShowDialog()) {
|
|
|
+ feedback.hideDialog();
|
|
|
+ }
|
|
|
+ if (pathname !== "/") {
|
|
|
+ setPopData([]);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ getData();
|
|
|
}, [pathname]);
|
|
|
-
|
|
|
- const doShowProxyCheck = async () => {
|
|
|
- const showProxy = sessionStorage.getItem("ShowProxy");
|
|
|
- if (!showProxy) {
|
|
|
- await feedback.showModal({
|
|
|
- content: <Agent step={1}></Agent>,
|
|
|
- width: "90%",
|
|
|
- useDefaultFooter: false,
|
|
|
- suffix: <AgentSuffix></AgentSuffix>,
|
|
|
- });
|
|
|
- await feedback.showModal({
|
|
|
- content: <Agent step={2}></Agent>,
|
|
|
- width: "90%",
|
|
|
- useDefaultFooter: false,
|
|
|
- suffix: <AgentSuffix></AgentSuffix>,
|
|
|
- });
|
|
|
- sessionStorage.setItem("ShowProxy", "1");
|
|
|
+ const getData = async () => {
|
|
|
+ commonMask.show();
|
|
|
+ try {
|
|
|
+ const res = await getPromotions();
|
|
|
+ if (res?.code === 200 && res?.data?.length) {
|
|
|
+ setPopData(res.data);
|
|
|
+ if (!res.data?.length) {
|
|
|
+ commonMask.hide();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch {
|
|
|
+ commonMask.hide();
|
|
|
}
|
|
|
};
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ doAutoDialog(popData);
|
|
|
+ }, [popData]);
|
|
|
+
|
|
|
+ // const doShowProxyCheck = async () => {
|
|
|
+ // const showProxy = sessionStorage.getItem("ShowProxy");
|
|
|
+ // if (!showProxy) {
|
|
|
+ // await feedback.showModal({
|
|
|
+ // content: <Agent step={1}></Agent>,
|
|
|
+ // width: "90%",
|
|
|
+ // useDefaultFooter: false,
|
|
|
+ // suffix: <AgentSuffix></AgentSuffix>,
|
|
|
+ // });
|
|
|
+ // await feedback.showModal({
|
|
|
+ // content: <Agent step={2}></Agent>,
|
|
|
+ // width: "90%",
|
|
|
+ // useDefaultFooter: false,
|
|
|
+ // suffix: <AgentSuffix></AgentSuffix>,
|
|
|
+ // });
|
|
|
+ // sessionStorage.setItem("ShowProxy", "1");
|
|
|
+ // }
|
|
|
+ // };
|
|
|
return (
|
|
|
<div id={"app"} className="relative h-[100%] overflow-hidden">
|
|
|
<motion.div
|