|
@@ -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} />
|
|
|
</>
|
|
|
);
|
|
|
};
|