he wei
2022-11-13 b4816f6294646157b50bb49f1d19eaf306e0ac8c
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);
      }
    },