11<script setup>
2- import { ref , useTemplateRef , onMounted , onUnmounted , watchEffect } from ' vue' ;
3- import { useForm } from ' @inertiajs/vue3' ;
2+ import { ref , computed , useTemplateRef , onMounted , onUnmounted , watchEffect } from ' vue' ;
3+ import { usePage , useForm } from ' @inertiajs/vue3' ;
44import ApplicationLogo from ' @/Components/ApplicationLogo.vue' ;
55import LinksMenu from ' @/Components/PrimeVue/LinksMenu.vue' ;
66import LinksMenuBar from ' @/Components/PrimeVue/LinksMenuBar.vue' ;
77import LinksPanelMenu from ' @/Components/PrimeVue/LinksPanelMenu.vue' ;
88import ToggleDarkModeButton from ' @/Components/ToggleDarkModeButton.vue' ;
99
10- const currentRoute = route ().current ();
10+ const page = usePage ();
11+ const currentRoute = computed (() => {
12+ // Access page.url to trigger re-computation on navigation.
13+ /* eslint-disable @typescript-eslint/no-unused-vars */
14+ const url = page .url ;
15+ /* eslint-enable @typescript-eslint/no-unused-vars */
16+ return route ().current ();
17+ });
18+
1119const logoutForm = useForm ({});
1220function logout () {
1321 logoutForm .post (route (' logout' ));
1422}
1523
1624// Main menu
17- const mainMenuItems = [
25+ const mainMenuItems = computed (() => [
1826 {
1927 label: ' Dashboard' ,
2028 route: route (' dashboard' ),
21- active: currentRoute == ' dashboard' ,
29+ active: currentRoute . value == ' dashboard' ,
2230 },
23- ];
31+ ]) ;
2432
2533// User menu (desktop)
2634const userMenu = useTemplateRef (' user-menu' );
@@ -43,18 +51,18 @@ const toggleUserMenu = (event) => {
4351};
4452
4553// Mobile menu (Drawer)
46- const homeMobileMenuItems = ref ( [
54+ const homeMobileMenuItems = computed (() => [
4755 {
4856 label: ' Welcome' ,
4957 icon: ' pi pi-home' ,
5058 route: route (' welcome' ),
51- active: currentRoute == ' welcome' ,
59+ active: currentRoute . value == ' welcome' ,
5260 },
5361 {
5462 label: ' Dashboard' ,
5563 icon: ' pi pi-th-large' ,
5664 route: route (' dashboard' ),
57- active: currentRoute == ' dashboard' ,
65+ active: currentRoute . value == ' dashboard' ,
5866 },
5967]);
6068const mobileMenuOpen = ref (false );
@@ -80,15 +88,12 @@ if (import.meta.env.SSR === false) {
8088< template>
8189 < div>
8290 < div class = " min-h-screen" >
83- < nav
84- class = " dynamic-bg border-b"
85- : class = " $slots.header ? 'dynamic-border' : 'shadow-sm'"
86- >
91+ < nav class = " dynamic-bg shadow-sm" >
8792 <!-- Primary Navigation Menu -->
8893 < Container>
8994 < LinksMenuBar
9095 : model= " mainMenuItems"
91- pt: root: class = " px-0 py-3 border-0 rounded-none dynamic-bg"
96+ pt: root: class = " px-0 py-4 border-0 rounded-none dynamic-bg"
9297 pt: button: class = " hidden"
9398 >
9499 < template #start>
@@ -116,7 +121,7 @@ if (import.meta.env.SSR === false) {
116121 id= " user-menu-btn"
117122 text
118123 severity= " secondary"
119- : label= " $ page.props.auth.user.name"
124+ : label= " page.props.auth.user.name"
120125 icon= " pi pi-angle-down"
121126 iconPos= " right"
122127 @click= " toggleUserMenu($event)"
@@ -203,18 +208,6 @@ if (import.meta.env.SSR === false) {
203208 < / Drawer>
204209 < / nav>
205210
206- <!-- Page Heading -->
207- < header
208- v- if = " $slots.header"
209- class = " dynamic-bg shadow-sm"
210- >
211- < Container>
212- < div class = " py-6" >
213- < slot name= " header" / >
214- < / div>
215- < / Container>
216- < / header>
217-
218211 <!-- Page Content -->
219212 < Toast position= " top-center" / >
220213 < main>
0 commit comments