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 );
@@ -78,15 +86,12 @@ watchEffect(() => {
7886<template >
7987 <div >
8088 <div class =" min-h-screen" >
81- <nav
82- class =" dynamic-bg border-b"
83- :class =" $slots.header ? 'dynamic-border' : 'shadow-sm'"
84- >
89+ <nav class =" dynamic-bg shadow-sm" >
8590 <!-- Primary Navigation Menu -->
8691 <Container >
8792 <LinksMenuBar
8893 :model =" mainMenuItems"
89- pt:root:class =" px-0 py-3 border-0 rounded-none dynamic-bg"
94+ pt:root:class =" px-0 py-4 border-0 rounded-none dynamic-bg"
9095 pt:button:class =" hidden"
9196 >
9297 <template #start >
@@ -114,7 +119,7 @@ watchEffect(() => {
114119 id =" user-menu-btn"
115120 text
116121 severity =" secondary"
117- :label =" $ page.props.auth.user.name"
122+ :label =" page.props.auth.user.name"
118123 icon =" pi pi-angle-down"
119124 iconPos =" right"
120125 @click =" toggleUserMenu($event)"
@@ -201,18 +206,6 @@ watchEffect(() => {
201206 </Drawer >
202207 </nav >
203208
204- <!-- Page Heading -->
205- <header
206- v-if =" $slots.header"
207- class =" dynamic-bg shadow-sm"
208- >
209- <Container >
210- <div class =" py-6" >
211- <slot name =" header" />
212- </div >
213- </Container >
214- </header >
215-
216209 <!-- Page Content -->
217210 <Toast position =" top-center" />
218211 <main >
0 commit comments