fix(fe): fix missing Vue hook imports in KsSidebar for TypeScript build verification
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed } from 'vue'
|
import { ref, computed, onMounted, watch } from 'vue'
|
||||||
import { useRouter, useRoute } from 'vue-router'
|
import { useRouter, useRoute } from 'vue-router'
|
||||||
import { useAnimatedCollapse } from '../composables/useAnimatedCollapse'
|
import { useAnimatedCollapse } from '../composables/useAnimatedCollapse'
|
||||||
|
|
||||||
@@ -83,14 +83,34 @@ const menuItems: MenuItem[] = [
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
// Auto-expand sections based on current active route
|
||||||
|
onMounted(() => {
|
||||||
|
menuItems.forEach(item => {
|
||||||
|
if (item.children?.some(c => c.path === route.path)) {
|
||||||
|
expandedSections.value.add(item.id)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(() => route.path, (newPath) => {
|
||||||
|
menuItems.forEach(item => {
|
||||||
|
if (item.children?.some(c => c.path === newPath)) {
|
||||||
|
expandedSections.value.add(item.id)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}, { immediate: true })
|
||||||
|
|
||||||
const isActive = (path: string) => route.path === path
|
const isActive = (path: string) => route.path === path
|
||||||
|
|
||||||
const toggleSection = (itemId: string) => {
|
const toggleSection = (itemId: string, defaultPath?: 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)
|
||||||
@@ -140,7 +160,7 @@ const sidebarClass = computed(() => ({
|
|||||||
},
|
},
|
||||||
]"
|
]"
|
||||||
:title="item.label"
|
:title="item.label"
|
||||||
@click="item.children ? toggleSection(item.id) : handleMenuClick(item.path)"
|
@click="item.children ? toggleSection(item.id, item.path) : 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