fix(fe): refine sidebar section toggle to avoid unnecessary page re-navigation
This commit is contained in:
@@ -102,15 +102,12 @@ watch(() => route.path, (newPath) => {
|
|||||||
|
|
||||||
const isActive = (path: string) => route.path === path
|
const isActive = (path: string) => route.path === path
|
||||||
|
|
||||||
const toggleSection = (itemId: string, defaultPath?: string) => {
|
const toggleSection = (itemId: string) => {
|
||||||
if (expandedSections.value.has(itemId)) {
|
if (expandedSections.value.has(itemId)) {
|
||||||
expandedSections.value.delete(itemId)
|
expandedSections.value.delete(itemId)
|
||||||
} else {
|
} else {
|
||||||
expandedSections.value.add(itemId)
|
expandedSections.value.add(itemId)
|
||||||
}
|
}
|
||||||
if (defaultPath) {
|
|
||||||
router.push(defaultPath)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const isSectionExpanded = (itemId: string) => expandedSections.value.has(itemId)
|
const isSectionExpanded = (itemId: string) => expandedSections.value.has(itemId)
|
||||||
@@ -160,7 +157,7 @@ const sidebarClass = computed(() => ({
|
|||||||
},
|
},
|
||||||
]"
|
]"
|
||||||
:title="item.label"
|
:title="item.label"
|
||||||
@click="item.children ? toggleSection(item.id, item.path) : handleMenuClick(item.path)"
|
@click="item.children ? toggleSection(item.id) : handleMenuClick(item.path)"
|
||||||
>
|
>
|
||||||
<span class="ks-sidebar__icon">{{ item.icon }}</span>
|
<span class="ks-sidebar__icon">{{ item.icon }}</span>
|
||||||
<span class="ks-sidebar__label">{{ item.label }}</span>
|
<span class="ks-sidebar__label">{{ item.label }}</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user