This commit is contained in:
2026-01-14 14:49:08 +08:00
parent 2ce76820da
commit 7065e5329a
23 changed files with 2236 additions and 413 deletions
+30
View File
@@ -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,
}
})