From c06ce947464b6b240764da31bd3d3a92cc2a5e45 Mon Sep 17 00:00:00 2001
From: xiaoxian521 <1923740402@qq.com>
Date: Fri, 9 Jun 2023 18:03:37 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AF=B9=E6=9C=AA=E8=A7=A3=E7=BB=91?=
=?UTF-8?q?=E7=9A=84=E5=85=AC=E5=85=B1=E4=BA=8B=E4=BB=B6=EF=BC=8C=E5=9C=A8?=
=?UTF-8?q?=E9=A1=B5=E9=9D=A2=E9=94=80=E6=AF=81=E6=97=B6=E8=A7=A3=E7=BB=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/layout/components/panel/index.vue | 13 ++++++--
src/layout/components/sidebar/vertical.vue | 19 ++++++-----
src/layout/components/tag/index.vue | 33 +++++++++++---------
src/utils/mitt.ts | 1 -
src/views/pure-table/high.vue | 8 +----
src/views/pure-table/high/adaptive/index.vue | 15 +--------
6 files changed, 43 insertions(+), 46 deletions(-)
diff --git a/src/layout/components/panel/index.vue b/src/layout/components/panel/index.vue
index d5f4f5a2a..59001f08c 100644
--- a/src/layout/components/panel/index.vue
+++ b/src/layout/components/panel/index.vue
@@ -1,7 +1,7 @@
diff --git a/src/layout/components/sidebar/vertical.vue b/src/layout/components/sidebar/vertical.vue
index 7f137aeb9..d97d16f98 100644
--- a/src/layout/components/sidebar/vertical.vue
+++ b/src/layout/components/sidebar/vertical.vue
@@ -7,9 +7,9 @@ import leftCollapse from "./leftCollapse.vue";
import { useNav } from "@/layout/hooks/useNav";
import { storageLocal } from "@pureadmin/utils";
import { responsiveStorageNameSpace } from "@/config";
-import { ref, computed, watch, onBeforeMount } from "vue";
import { findRouteByPath, getParentPaths } from "@/router/utils";
import { usePermissionStoreHook } from "@/store/modules/permission";
+import { ref, computed, watch, onMounted, onBeforeUnmount } from "vue";
const route = useRoute();
const showLogo = ref(
@@ -51,12 +51,6 @@ function getSubMenuData(path: string) {
getSubMenuData(route.path);
-onBeforeMount(() => {
- emitter.on("logoChange", key => {
- showLogo.value = key;
- });
-});
-
watch(
() => [route.path, usePermissionStoreHook().wholeMenus],
() => {
@@ -65,6 +59,17 @@ watch(
menuSelect(route.path, routers);
}
);
+
+onMounted(() => {
+ emitter.on("logoChange", key => {
+ showLogo.value = key;
+ });
+});
+
+onBeforeUnmount(() => {
+ // 解绑`logoChange`公共事件,防止多次触发
+ emitter.off("logoChange");
+});
diff --git a/src/layout/components/tag/index.vue b/src/layout/components/tag/index.vue
index e608cf9d2..7b2f2765e 100644
--- a/src/layout/components/tag/index.vue
+++ b/src/layout/components/tag/index.vue
@@ -8,7 +8,7 @@ import { isEqual, isAllEmpty } from "@pureadmin/utils";
import { handleAliveRoute, getTopMenu } from "@/router/utils";
import { useSettingStoreHook } from "@/store/modules/settings";
import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
-import { ref, watch, unref, toRaw, nextTick, onBeforeMount } from "vue";
+import { ref, watch, unref, toRaw, nextTick, onBeforeUnmount } from "vue";
import { useResizeObserver, useDebounceFn, useFullscreen } from "@vueuse/core";
import ExitFullscreen from "@iconify-icons/ri/fullscreen-exit-fill";
@@ -465,7 +465,17 @@ function tagOnClick(item) {
// showMenuModel(item?.path, item?.query);
}
-onBeforeMount(() => {
+watch([route], () => {
+ activeIndex.value = -1;
+ dynamicTagView();
+});
+
+watch(isFullscreen, () => {
+ tagsViews[6].icon = Fullscreen;
+ tagsViews[6].text = $t("buttons.hswholeFullScreen");
+});
+
+onMounted(() => {
if (!instance) return;
// 根据当前路由初始化操作标签页的禁用状态
@@ -489,19 +499,7 @@ onBeforeMount(() => {
showMenuModel(indexPath);
});
});
-});
-watch([route], () => {
- activeIndex.value = -1;
- dynamicTagView();
-});
-
-watch(isFullscreen, () => {
- tagsViews[6].icon = Fullscreen;
- tagsViews[6].text = $t("buttons.hswholeFullScreen");
-});
-
-onMounted(() => {
useResizeObserver(
scrollbarDom,
useDebounceFn(() => {
@@ -509,6 +507,13 @@ onMounted(() => {
}, 200)
);
});
+
+onBeforeUnmount(() => {
+ // 解绑`tagViewsChange`、`tagViewsShowModel`、`changLayoutRoute`公共事件,防止多次触发
+ emitter.off("tagViewsChange");
+ emitter.off("tagViewsShowModel");
+ emitter.off("changLayoutRoute");
+});
diff --git a/src/utils/mitt.ts b/src/utils/mitt.ts
index 11845a3e1..0022e8dbb 100644
--- a/src/utils/mitt.ts
+++ b/src/utils/mitt.ts
@@ -16,7 +16,6 @@ type Events = {
indexPath: string;
parentPath: string;
};
- setAdaptive: string;
};
export const emitter: Emitter = mitt();
diff --git a/src/views/pure-table/high.vue b/src/views/pure-table/high.vue
index 01de09181..66780e9f8 100644
--- a/src/views/pure-table/high.vue
+++ b/src/views/pure-table/high.vue
@@ -1,7 +1,6 @@
diff --git a/src/views/pure-table/high/adaptive/index.vue b/src/views/pure-table/high/adaptive/index.vue
index 7aa3dbd3c..0536bdff1 100644
--- a/src/views/pure-table/high/adaptive/index.vue
+++ b/src/views/pure-table/high/adaptive/index.vue
@@ -1,7 +1,6 @@