Browse Source

feat: 修改首页弹窗问题

year 1 week ago
parent
commit
0090a4822d
4 changed files with 29 additions and 7 deletions
  1. 9 4
      src/dialog/auto.ts
  2. 8 1
      src/dialog/img/index.tsx
  3. 8 2
      src/dialog/manager.ts
  4. 4 0
      src/dialog/text/index.tsx

+ 9 - 4
src/dialog/auto.ts

@@ -143,18 +143,18 @@ const AutoShowDialog = () => {
             // await dialogManage.showDialog('SignInSection', curData);  //签到
             // await dialogManage.showDialog("SignInSection", curData);
             try {
+                let res: any = "";
                 switch (curData.content_type) {
                     // 图片展示
                     case 1:
-                        await dialogManage.showDialog("ImgDialog", curData);
+                        res = await dialogManage.showDialog("ImgDialog", curData);
                         break;
                     // 富文本展示
                     case 2:
-                        await dialogManage.showDialog("TextDialog", curData);
+                        res = await dialogManage.showDialog("TextDialog", curData);
                         break;
                     case 3:
                         // 轮盘特殊处理 dialogManage.showDialog('WheelSection')
-
                         if (curData?.action_params?.includes("WheelSection")) {
                             await wheelState.setWheel();
                             if (wheelState.status != 1) {
@@ -162,10 +162,15 @@ const AutoShowDialog = () => {
                             }
                         }
                         if (curData.action_type === 5) {
-                            curData?.action_params ? await eval(curData?.action_params || "") : "";
+                            res = curData?.action_params
+                                ? await eval(curData?.action_params || "")
+                                : "";
                         }
                         break;
                 }
+                if (res === "target") {
+                    return;
+                }
             } catch (err) {
                 saveShowIndex(i);
                 continue;

+ 8 - 1
src/dialog/img/index.tsx

@@ -71,7 +71,9 @@ const ImgDialog = () => {
                 if (data.activity_id) {
                     path = `${data.action_params}?activity_id=${data.activity_id}`;
                 }
-                if (path) router.push(path);
+                if (path) {
+                    router.push(path);
+                }
                 break;
             case 4:
                 if (data.action_params === ModalEnum.red_packet) {
@@ -87,6 +89,11 @@ const ImgDialog = () => {
             default:
                 break;
         }
+        setInnerVisible(false);
+        setTimeout(() => {
+            handler.hide();
+            dialogManage.goTarget(keyName);
+        }, 250);
     };
 
     return (

+ 8 - 2
src/dialog/manager.ts

@@ -13,7 +13,6 @@ class DialogManage {
         this._dialogs = new Map();
         this._resolves = new Map();
     }
-
     registerDialog({ key, show, hide }: RegisterParams) {
         this._dialogs.set(key, {
             key,
@@ -27,7 +26,6 @@ class DialogManage {
     showDialog(key: string, ...args: any[]) {
         return new Promise((resolve) => {
             const dialog = this._dialogs.get(key);
-
             if (dialog?.show) {
                 const res = dialog.show(...args);
                 if (res === "close") {
@@ -53,6 +51,14 @@ class DialogManage {
             this._resolves.delete(key);
         }
     }
+    goTarget(key: string) {
+        // const dialog = this._dialogs.get(key);
+        let resolveFun = this._resolves.get(key);
+        if (resolveFun && typeof resolveFun === "function") {
+            resolveFun("target");
+            this._resolves.delete(key);
+        }
+    }
 }
 
 const dialogManage = new DialogManage();

+ 4 - 0
src/dialog/text/index.tsx

@@ -60,6 +60,10 @@ const ImgDialog = () => {
             default:
                 break;
         }
+        setTimeout(() => {
+            handler.hide();
+            dialogManage.goTarget(keyName);
+        }, 250);
     };
 
     return (