11import { defineComponent , h , onMounted , ref , resolveComponent } from 'vue'
22import { RouterLink , useRoute } from 'vue-router'
33
4- import { CBadge , CSidebarNav , CNavItem , CNavGroup , CNavTitle } from '@coreui/vue'
4+ import {
5+ CBadge ,
6+ CSidebarNav ,
7+ CNavItem ,
8+ CNavGroup ,
9+ CNavTitle ,
10+ } from '@coreui/vue'
511import nav from '@/_nav.js'
612
713const normalizePath = ( path ) =>
8- decodeURI ( path )
9- . replace ( / # .* $ / , '' )
10- . replace ( / ( i n d e x ) ? \. ( h t m l ) $ / , '' )
14+ decodeURI ( path )
15+ . replace ( / # .* $ / , '' )
16+ . replace ( / ( i n d e x ) ? \. ( h t m l ) $ / , '' )
1117
1218const isActiveLink = ( route , link ) => {
13- if ( link === undefined ) {
14- return false
15- }
19+ if ( link === undefined ) {
20+ return false
21+ }
1622
17- if ( route . hash === link ) {
18- return true
19- }
23+ if ( route . hash === link ) {
24+ return true
25+ }
2026
21- const currentPath = normalizePath ( route . path )
22- const targetPath = normalizePath ( link )
27+ const currentPath = normalizePath ( route . path )
28+ const targetPath = normalizePath ( link )
2329
24- return currentPath === targetPath
30+ return currentPath === targetPath
2531}
2632
2733const isActiveItem = ( route , item ) => {
28- if ( isActiveLink ( route , item . to ) ) {
29- return true
30- }
34+ if ( isActiveLink ( route , item . to ) ) {
35+ return true
36+ }
3137
32- if ( item . items ) {
33- return item . items . some ( ( child ) => isActiveItem ( route , child ) )
34- }
38+ if ( item . items ) {
39+ return item . items . some ( ( child ) => isActiveItem ( route , child ) )
40+ }
3541
36- return false
42+ return false
3743}
3844
3945const AppSidebarNav = defineComponent ( {
@@ -56,7 +62,9 @@ const AppSidebarNav = defineComponent({
5662 return h (
5763 CNavGroup ,
5864 {
59- ...firstRender . value && { visible : item . items . some ( ( child ) => isActiveItem ( route , child ) ) }
65+ ...( firstRender . value && {
66+ visible : item . items . some ( ( child ) => isActiveItem ( route , child ) ) ,
67+ } ) ,
6068 } ,
6169 {
6270 togglerContent : ( ) => [
0 commit comments