From b4816f6294646157b50bb49f1d19eaf306e0ac8c Mon Sep 17 00:00:00 2001
From: he wei <858544502@qq.com>
Date: 星期日, 13 十一月 2022 22:06:22 +0800
Subject: [PATCH] UA 0.1.4发布

---
 src/components/tabsBar.vue |   38 +++++++++++++++++++++++++++++---------
 1 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/src/components/tabsBar.vue b/src/components/tabsBar.vue
index 7e96cde..103b956 100644
--- a/src/components/tabsBar.vue
+++ b/src/components/tabsBar.vue
@@ -62,11 +62,31 @@
       if (page) {
         page.fullPath = newRoute.fullPath;
       } else if (!page) {
+        // 濡傛灉鏂板鐨勬槸鏂囦欢缁撴灉鎴栧姣旈〉闈� 鍒欐竻闄ゅ悓绫�
+        if (newRoute.name == "result" || newRoute.name == 'compare') {
+          // 娓呴櫎缂撳瓨
+          const clearPages = this.pageList.filter(
+            (item) => item.name == "result" || item.name == 'compare'
+          );
+          this.$bus.$emit(
+            "clearCaches",
+            clearPages.map((item) => item.cachedKey)
+          );
+          this.pageList = this.pageList.filter(
+            (item) => !clearPages.includes(item)
+          );
+        }
+        /////////////////////
+        // 娣诲姞鏂扮
         this.pageList.push(this.createPage(newRoute));
       }
       this.$nextTick(() => {
         this.setCachedKey(newRoute);
       });
+    },
+    pageList(n) {
+      let hasFile = n.some((v) => ["compare", "result"].includes(v.name));
+      this.$bus.$emit("checkCloseAll", hasFile);
     },
   },
   computed: {
@@ -175,12 +195,11 @@
         remove.map((page) => page.cachedKey)
       );
       if (path === this.activePage) {
-        index =
-          index >= this.pageList.length ? this.pageList.length - 1 : index;
-        this.activePage = this.pageList.length
-          ? this.pageList[index].path
-          : "/";
-        const nextPage = this.pageList.length ? this.pageList[index] : {path: '/'};
+        this.pageList.sort((a, b) => (b.path == "/empty" ? -1 : 0));
+        this.activePage = this.pageList.length ? this.pageList[0].path : "/";
+        const nextPage = this.pageList.length
+          ? this.pageList[0]
+          : { path: "/" };
         if ("result" == nextPage.name) {
           this.$router.push({
             path: "/result/" + nextPage.title,
@@ -188,7 +207,7 @@
           });
           this.$bus.$emit("chartResize");
         } else {
-          this.$router.push({path: nextPage.path, query: nextPage.query});
+          this.$router.push({ path: nextPage.path, query: nextPage.query });
           // this.$router.push(this.activePage);
         }
       }
@@ -204,10 +223,11 @@
       this.pageList = this.pageList.filter(
         (item) => !clearPages.includes(item)
       );
+      this.pageList.sort((a, b) => (b.path == "/empty" ? -1 : 0));
       const nextPage = this.pageList.length ? this.pageList[0] : {};
       this.activePage = nextPage.path || "/";
       // 鍒ゆ柇璺宠浆
-      this.$router.push({path: nextPage.path, query: nextPage.query});
+      this.$router.push({ path: nextPage.path, query: nextPage.query });
       // this.$router.push(this.activePage);
     },
     onTabClick(page) {
@@ -222,7 +242,7 @@
         });
         this.$bus.$emit("chartResize");
       } else {
-        this.$router.push({path, query});
+        this.$router.push({ path, query });
         // this.$router.push(this.activePage);
       }
     },

--
Gitblit v1.9.1