fix: 修复打包部署后或 preview 模式下,布局切换及页签显示异常

Closes #I9OHTJ
Closes #I9OHQ5
This commit is contained in:
2024-05-13 21:31:22 +08:00
parent 2d8e6ae3bb
commit 68d8f0f5b3
2 changed files with 4 additions and 5 deletions

View File

@@ -56,8 +56,8 @@ tabsStore.reset()
// 路由发生改变触发 // 路由发生改变触发
const handleRouteChange = () => { const handleRouteChange = () => {
const item = { ...route } as unknown as RouteRecordRaw const item = { ...route } as unknown as RouteRecordRaw
tabsStore.addTagItem(item) tabsStore.addTagItem(toRaw(item))
tabsStore.addCacheItem(item) tabsStore.addCacheItem(toRaw(item))
// console.log('路由对象', toRaw(item)) // console.log('路由对象', toRaw(item))
// console.log('tagList', toRaw(tabsStore.tagList)) // console.log('tagList', toRaw(tabsStore.tagList))
// console.log('cacheList', toRaw(tabsStore.cacheList)) // console.log('cacheList', toRaw(tabsStore.cacheList))

View File

@@ -10,8 +10,7 @@ const storeSetup = () => {
const cacheList = ref<RouteRecordName[]>([]) // keep-alive缓存的数组, 元素是组件名 const cacheList = ref<RouteRecordName[]>([]) // keep-alive缓存的数组, 元素是组件名
// 添加一个页签, 如果当前路由已经打开, 则不再重复添加 // 添加一个页签, 如果当前路由已经打开, 则不再重复添加
const addTagItem = (route: RouteRecordRaw) => { const addTagItem = (item: RouteRecordRaw) => {
const item = JSON.parse(JSON.stringify(route))
if (tagList.value.some((i) => i.path === item.path)) return if (tagList.value.some((i) => i.path === item.path)) return
if (item.meta?.showInTabs ?? true) { if (item.meta?.showInTabs ?? true) {
tagList.value.push(item) tagList.value.push(item)
@@ -36,7 +35,7 @@ const storeSetup = () => {
const arr: RouteRecordRaw[] = [] const arr: RouteRecordRaw[] = []
_XEUtils_.eachTree(routeStore.routes, (item) => { _XEUtils_.eachTree(routeStore.routes, (item) => {
if (item.meta?.affix ?? false) { if (item.meta?.affix ?? false) {
arr.push(JSON.parse(JSON.stringify(item))) arr.push(item)
} }
}) })
tagList.value = arr tagList.value = arr