Files
analiticaNucleo/nuxt4-app/plugins/loading.client.ts

22 lines
640 B
TypeScript

export default defineNuxtPlugin(() => {
// This plugin ensures the loading screen is properly hidden when the app is ready
if (process.client) {
// Listen for when the app is fully hydrated
const checkReady = () => {
// Wait for next tick to ensure DOM is painted
requestAnimationFrame(() => {
setTimeout(() => {
document.documentElement.classList.add('nuxt-ready')
}, 50)
})
}
// Multiple triggers to ensure loading screen is hidden
if (document.readyState === 'complete') {
checkReady()
} else {
window.addEventListener('load', checkReady)
}
}
})