mirror of
https://github.com/fugary/simple-element-plus-template.git
synced 2026-02-23 06:37:01 +00:00
依赖设计与控件优化
This commit is contained in:
@@ -68,7 +68,10 @@ export const useTabsViewStore = defineStore('tabsView', () => {
|
||||
}
|
||||
|
||||
const findHistoryTab = (path) => {
|
||||
const idx = historyTabs.value.findIndex(v => v.path === path)
|
||||
let idx = historyTabs.value.findIndex(v => v.path === path)
|
||||
if (idx === -1) {
|
||||
idx = historyTabs.value.findIndex(v => v.fullPath === path)
|
||||
}
|
||||
if (idx > -1) {
|
||||
return historyTabs.value[idx]
|
||||
}
|
||||
@@ -99,15 +102,22 @@ export const useTabsViewStore = defineStore('tabsView', () => {
|
||||
// 可能是Proxy,需要解析出来
|
||||
isHomeTab(tab) ? historyTabs.value.unshift({ ...tab }) : historyTabs.value.push({ ...tab })
|
||||
}
|
||||
tab.accessTime = Date.now()
|
||||
if (isNestedRoute(tab)) {
|
||||
addNestedParentTab(tab, replaceTab)
|
||||
} else {
|
||||
addCachedTab(tab, replaceTab)
|
||||
}
|
||||
} else {
|
||||
historyTabs.value[idx].accessTime = Date.now()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const findLastTab = () => {
|
||||
return historyTabs.value.toSorted((a, b) => b.accessTime - a.accessTime)?.[0]
|
||||
}
|
||||
|
||||
const removeHistoryTab = tab => {
|
||||
if (historyTabs.value.length > 1) {
|
||||
const idx = historyTabs.value.findIndex(v => v.path === tab.path)
|
||||
@@ -116,7 +126,7 @@ export const useTabsViewStore = defineStore('tabsView', () => {
|
||||
// 删除tab
|
||||
historyTabs.value.splice(idx, 1)
|
||||
}
|
||||
return historyTabs.value[historyTabs.value.length - 1]
|
||||
return findLastTab()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,5 +237,7 @@ export const useTabsViewStore = defineStore('tabsView', () => {
|
||||
hasCloseDropdown
|
||||
}
|
||||
}, {
|
||||
persist: { serializer }
|
||||
persist: {
|
||||
serializer
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user