From 68d8f0f5b36be162a0c64d500d845388c239c4a7 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Mon, 13 May 2024 21:31:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=89=93=E5=8C=85?= =?UTF-8?q?=E9=83=A8=E7=BD=B2=E5=90=8E=E6=88=96=20preview=20=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E4=B8=8B=EF=BC=8C=E5=B8=83=E5=B1=80=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E5=8F=8A=E9=A1=B5=E7=AD=BE=E6=98=BE=E7=A4=BA=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #I9OHTJ Closes #I9OHQ5 --- src/layout/components/Tabs/index.vue | 4 ++-- src/stores/modules/tabs.ts | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/layout/components/Tabs/index.vue b/src/layout/components/Tabs/index.vue index f23f5ae..ba06949 100644 --- a/src/layout/components/Tabs/index.vue +++ b/src/layout/components/Tabs/index.vue @@ -56,8 +56,8 @@ tabsStore.reset() // 路由发生改变触发 const handleRouteChange = () => { const item = { ...route } as unknown as RouteRecordRaw - tabsStore.addTagItem(item) - tabsStore.addCacheItem(item) + tabsStore.addTagItem(toRaw(item)) + tabsStore.addCacheItem(toRaw(item)) // console.log('路由对象', toRaw(item)) // console.log('tagList', toRaw(tabsStore.tagList)) // console.log('cacheList', toRaw(tabsStore.cacheList)) diff --git a/src/stores/modules/tabs.ts b/src/stores/modules/tabs.ts index a63a458..e4f36e0 100644 --- a/src/stores/modules/tabs.ts +++ b/src/stores/modules/tabs.ts @@ -10,8 +10,7 @@ const storeSetup = () => { const cacheList = ref([]) // keep-alive缓存的数组, 元素是组件名 // 添加一个页签, 如果当前路由已经打开, 则不再重复添加 - const addTagItem = (route: RouteRecordRaw) => { - const item = JSON.parse(JSON.stringify(route)) + const addTagItem = (item: RouteRecordRaw) => { if (tagList.value.some((i) => i.path === item.path)) return if (item.meta?.showInTabs ?? true) { tagList.value.push(item) @@ -36,7 +35,7 @@ const storeSetup = () => { const arr: RouteRecordRaw[] = [] _XEUtils_.eachTree(routeStore.routes, (item) => { if (item.meta?.affix ?? false) { - arr.push(JSON.parse(JSON.stringify(item))) + arr.push(item) } }) tagList.value = arr