tab模式在production下切换失效问题

This commit is contained in:
gary.fu
2024-07-03 17:48:03 +08:00
parent 2e2b13ae1c
commit bc91df5b01
2 changed files with 21 additions and 2 deletions

View File

@@ -6,6 +6,25 @@ import {
} from '@/route/RouteUtils'
import { TAB_MODE_MAX_CACHES } from '@/config'
const pureTab = tab => {
if (tab) {
return {
...tab,
matched: undefined
}
}
}
const serializer = {
serialize (state) {
const newState = { ...state }
newState.historyTabs = state.historyTabs?.map(pureTab)
newState.currentTabItem = pureTab(state.currentTabItem)
return JSON.stringify(newState)
},
deserialize: JSON.parse
}
/**
* @typedef {Object} TabsViewStore
* @property {boolean} isTabMode 是否开启tab模式
@@ -208,5 +227,5 @@ export const useTabsViewStore = defineStore('tabsView', () => {
hasCloseDropdown
}
}, {
persist: true
persist: { serializer }
})