1
1
<script setup>
2
2
import { ref , computed } from ' vue'
3
- import { Link } from ' @inertiajs/vue3'
3
+ import { Link , usePage } from ' @inertiajs/vue3'
4
4
import { useStyleStore } from ' @/Stores/style.js'
5
5
import { mdiMinus , mdiPlus } from ' @mdi/js'
6
6
import { getButtonColor } from ' @/colors.js'
@@ -15,9 +15,11 @@ const props = defineProps({
15
15
isDropdownList: Boolean ,
16
16
})
17
17
18
+ const { url , component } = usePage ()
19
+
18
20
const itemHref = computed (() => (props .item && props .item .link ) ? props .item .link : ' ' )
19
21
20
- const emit = defineEmits ([' menu-click' ])
22
+ const emit = defineEmits ([' menu-click' , ' dropdown-active ' ])
21
23
22
24
const styleStore = useStyleStore ()
23
25
@@ -46,10 +48,20 @@ const menuClick = event => {
46
48
}
47
49
}
48
50
51
+ const dropdownActive = value => {
52
+ isDropdownActive .value = value;
53
+ }
54
+
49
55
const activeInactiveStyle = computed (
50
- () => props .item .route && route ().current (props .item .route )
51
- ? styleStore .asideMenuItemActiveStyle
52
- : ' '
56
+ () => {
57
+ if (props .item .link && url === props .item .link ) {
58
+ emit (' dropdown-active' , true )
59
+ return styleStore .asideMenuItemActiveStyle
60
+ }
61
+ else {
62
+ return ' '
63
+ }
64
+ }
53
65
)
54
66
</script >
55
67
@@ -88,6 +100,7 @@ const activeInactiveStyle = computed(
88
100
:menu =" item.children"
89
101
:class =" [ styleStore.asideMenuDropdownStyle, isDropdownActive ? 'block dark:bg-slate-800/50' : 'hidden' ]"
90
102
is-dropdown-list
103
+ @dropdown-active =" dropdownActive"
91
104
/>
92
105
</li >
93
106
</template >
0 commit comments