fix : reset sidebar state on logout
Add resetSidebar() to useSidebar composable and call it on logout to prevent stale sidebar data after re-login. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -8,9 +8,11 @@
|
|||||||
definePageMeta({ layout: 'auth' })
|
definePageMeta({ layout: 'auth' })
|
||||||
|
|
||||||
const auth = useAuthStore()
|
const auth = useAuthStore()
|
||||||
|
const { resetSidebar } = useSidebar()
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await auth.logout()
|
await auth.logout()
|
||||||
|
resetSidebar()
|
||||||
await navigateTo('/login')
|
await navigateTo('/login')
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -29,11 +29,18 @@ export function useSidebar() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resetSidebar() {
|
||||||
|
sections.value = []
|
||||||
|
disabledRoutes.value = []
|
||||||
|
loaded.value = false
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
sections,
|
sections,
|
||||||
disabledRoutes,
|
disabledRoutes,
|
||||||
loaded,
|
loaded,
|
||||||
loadSidebar,
|
loadSidebar,
|
||||||
|
resetSidebar,
|
||||||
isRouteDisabled,
|
isRouteDisabled,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user