Przeglądaj źródła

fix: 更新pwa安装弹窗

Before 8 miesięcy temu
rodzic
commit
dd1a7e5642

+ 1 - 1
.env.uat

@@ -1,5 +1,5 @@
 #baseurl
-NEXT_PUBLIC_BASE_URL=https://api.bcwin777.bet
+NEXT_PUBLIC_BASE_URL=https://ot-api.bcwin777.bet
 #share link
 NEXT_PUBLIC_SHARE_URL=https://ot-site.bcwin777.bet
 #firebase

+ 2 - 2
src/components/Box/Desktop.tsx

@@ -10,12 +10,12 @@ import { forwardRef, useEffect, useImperativeHandle, useRef } from "react";
  * if 下载 不弹窗 , else 弹窗
  *
  */
-export interface DesktopRef {
+export interface DesktopRefProps {
     onOpen: () => void;
     onClose: () => void;
 }
 interface Props {}
-const Desktop = forwardRef<DesktopRef, Props>(function Desktop(props, ref) {
+const Desktop = forwardRef<DesktopRefProps, Props>(function Desktop(props, ref) {
     const prompt = useRef<Event | null>(null);
 
     const t = useTranslations("HomePage");

+ 33 - 18
src/components/Box/index.tsx

@@ -9,6 +9,8 @@ import { Toast } from "antd-mobile";
 import clsx from "clsx";
 import { CSSProperties, FC, PropsWithChildren, useRef } from "react";
 import { twMerge } from "tailwind-merge";
+import DesktopModal, { DesktopRefProps } from "./Desktop";
+import { ModalEnum } from "./types";
 interface Props {
     pt?: boolean;
     pb?: boolean;
@@ -41,12 +43,6 @@ const openWindow = (url: string) => {
         Toast.show("非法地址");
     }
 };
-/**
- * @description 弹窗类型
- */
-enum ModalEnum {
-    red_packet = "red_packet",
-}
 
 /**
  * @description 红包雨验证
@@ -60,10 +56,37 @@ const isStartPacketsHandler = async () => {
         return redPacketInfo.data || [];
     }
 };
+
 const Box: FC<PropsWithChildren<Props>> = (props) => {
     const router = useRouter();
 
-    const RedPacketModalRef = useRef<RedPacketModalProps>(null);
+    const packetModalRef = useRef<RedPacketModalProps>(null);
+    const pwaModalRef = useRef<DesktopRefProps>(null);
+
+    /**
+     * @description 弹窗类型
+     */
+
+    const popupHandler = (actionData: keyof typeof ModalEnum) => {
+        console.log(`🚀🚀🚀🚀🚀-> in index.tsx on 71`, actionData);
+        switch (actionData) {
+            case ModalEnum.red_packet:
+                isStartPacketsHandler().then((data) => {
+                    if (data.length) {
+                        packetModalRef.current?.onOpen(data);
+                    } else {
+                        Toast.show("It is under development");
+                    }
+                });
+                break;
+            case ModalEnum.pwa_install:
+                pwaModalRef.current?.onOpen();
+                break;
+            default:
+                Toast.show("Unknown parameters");
+        }
+    };
+
     const {
         className,
         children,
@@ -89,7 +112,6 @@ const Box: FC<PropsWithChildren<Props>> = (props) => {
 
     const handler = () => {
         if (!action) return;
-        console.log(`🎯🎯🎯🎯🎯-> in index.tsx on 68`, action);
         switch (action) {
             case 1:
                 return;
@@ -100,15 +122,7 @@ const Box: FC<PropsWithChildren<Props>> = (props) => {
                 router.push(actionData as string);
                 break;
             case 4:
-                if (actionData === ModalEnum.red_packet) {
-                    isStartPacketsHandler().then((data) => {
-                        if (data.length) {
-                            RedPacketModalRef.current?.onOpen(data);
-                        } else {
-                            Toast.show("It is under development");
-                        }
-                    });
-                }
+                popupHandler(actionData as keyof typeof ModalEnum);
                 break;
             case 5:
                 break;
@@ -129,7 +143,8 @@ const Box: FC<PropsWithChildren<Props>> = (props) => {
                 {children}
             </Tag>
 
-            <RedPacketModal ref={RedPacketModalRef} />
+            <RedPacketModal ref={packetModalRef} />
+            <DesktopModal ref={pwaModalRef} />
         </>
     );
 };

+ 4 - 0
src/components/Box/types.ts

@@ -0,0 +1,4 @@
+export enum ModalEnum {
+    red_packet = "red_packet",
+    pwa_install = "pwa_install",
+}

+ 0 - 5
src/types/index.ts

@@ -50,8 +50,3 @@ export type Result<T> = {
     data: T;
 };
 export type Response<T> = T extends any[] ? Result<T> & { page: Pagination } : Result<T>;
-
-export enum PopupTypes {
-    red_packet = "red_packet",
-    pwa_install = "pwa_install",
-}