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 toggleSection = (itemId: string, defaultPath?: string) => {
|
||||
const toggleSection = (itemId: string) => {
|
||||
if (expandedSections.value.has(itemId)) {
|
||||
expandedSections.value.delete(itemId)
|
||||
} else {
|
||||
expandedSections.value.add(itemId)
|
||||
}
|
||||
if (defaultPath) {
|
||||
router.push(defaultPath)
|
||||
}
|
||||
}
|
||||
|
||||
const isSectionExpanded = (itemId: string) => expandedSections.value.has(itemId)
|
||||
@@ -160,7 +157,7 @@ const sidebarClass = computed(() => ({
|
||||
},
|
||||
]"
|
||||
: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__label">{{ item.label }}</span>
|
||||
|
||||
Reference in New Issue
Block a user