Optimize auth initialization by using cached middleware state
- Replace API calls with cached auth state from middleware in useAuthorization - Add fallback to session cache and watchers for auth state updates - Change initialization from async to synchronous for better performance - Add DuplicateNotificationBanner component
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
|
||||
<v-list color="primary" lines="two">
|
||||
<v-list-item
|
||||
v-for="(item, index) in menu"
|
||||
v-for="(item, index) in safeMenu"
|
||||
:key="index"
|
||||
:to="item.to"
|
||||
:title="item.title"
|
||||
@@ -191,6 +191,53 @@ const menu = computed(() =>
|
||||
toValue(tags).interest ? interestMenu : defaultMenu
|
||||
);
|
||||
|
||||
// Safe menu wrapper to prevent crashes when menu is undefined
|
||||
const safeMenu = computed(() => {
|
||||
try {
|
||||
const currentMenu = menu.value;
|
||||
if (Array.isArray(currentMenu)) {
|
||||
return currentMenu;
|
||||
}
|
||||
|
||||
console.warn('[Dashboard] Menu is not an array, returning fallback menu');
|
||||
|
||||
// Fallback menu with essential items (including admin for safety)
|
||||
return [
|
||||
{
|
||||
to: "/dashboard/interest-list",
|
||||
icon: "mdi-view-list",
|
||||
title: "Interest List",
|
||||
},
|
||||
{
|
||||
to: "/dashboard/expenses",
|
||||
icon: "mdi-receipt",
|
||||
title: "Expenses",
|
||||
},
|
||||
{
|
||||
to: "/dashboard/file-browser",
|
||||
icon: "mdi-folder",
|
||||
title: "File Browser",
|
||||
},
|
||||
{
|
||||
to: "/dashboard/admin",
|
||||
icon: "mdi-shield-crown",
|
||||
title: "Admin Console",
|
||||
},
|
||||
];
|
||||
} catch (error) {
|
||||
console.error('[Dashboard] Error computing menu:', error);
|
||||
|
||||
// Emergency fallback menu
|
||||
return [
|
||||
{
|
||||
to: "/dashboard/interest-list",
|
||||
icon: "mdi-view-list",
|
||||
title: "Interest List",
|
||||
},
|
||||
];
|
||||
}
|
||||
});
|
||||
|
||||
const logOut = async () => {
|
||||
await logout();
|
||||
return navigateTo("/login");
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
<template>
|
||||
<div>
|
||||
<v-container fluid>
|
||||
<!-- Duplicate notification banner for admins -->
|
||||
<DuplicateNotificationBanner />
|
||||
|
||||
<!-- Header Section -->
|
||||
<v-row class="mb-4 mb-md-6">
|
||||
<v-col cols="12" md="8">
|
||||
|
||||
Reference in New Issue
Block a user