更新
This commit is contained in:
@@ -8,6 +8,9 @@ export const useLayoutStore = defineStore('layout', () => {
|
||||
// 侧边栏折叠状态
|
||||
const sidebarCollapsed = ref(false)
|
||||
|
||||
// 视图标签页(用于记录页面滚动位置)
|
||||
const viewTags = ref([])
|
||||
|
||||
// 切换侧边栏折叠
|
||||
const toggleSidebar = () => {
|
||||
sidebarCollapsed.value = !sidebarCollapsed.value
|
||||
@@ -18,10 +21,37 @@ export const useLayoutStore = defineStore('layout', () => {
|
||||
layoutMode.value = mode
|
||||
}
|
||||
|
||||
// 更新视图标签
|
||||
const updateViewTags = (tag) => {
|
||||
const index = viewTags.value.findIndex((item) => item.fullPath === tag.fullPath)
|
||||
if (index !== -1) {
|
||||
viewTags.value[index] = tag
|
||||
} else {
|
||||
viewTags.value.push(tag)
|
||||
}
|
||||
}
|
||||
|
||||
// 移除视图标签
|
||||
const removeViewTags = (fullPath) => {
|
||||
const index = viewTags.value.findIndex((item) => item.fullPath === fullPath)
|
||||
if (index !== -1) {
|
||||
viewTags.value.splice(index, 1)
|
||||
}
|
||||
}
|
||||
|
||||
// 清空视图标签
|
||||
const clearViewTags = () => {
|
||||
viewTags.value = []
|
||||
}
|
||||
|
||||
return {
|
||||
layoutMode,
|
||||
sidebarCollapsed,
|
||||
viewTags,
|
||||
toggleSidebar,
|
||||
setLayoutMode,
|
||||
updateViewTags,
|
||||
removeViewTags,
|
||||
clearViewTags,
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user