From ae0ef63a0305a99cce02c9003ebc27298aee350f Mon Sep 17 00:00:00 2001 From: ShareVB Date: Sun, 17 Aug 2025 16:13:36 +0200 Subject: [PATCH] fix: tool loading indicator after 350ms only Fix #171 --- src/router.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/router.ts b/src/router.ts index 26496200..e06338d9 100644 --- a/src/router.ts +++ b/src/router.ts @@ -42,18 +42,25 @@ const router = createRouter({ }); let loader: ActiveLoader | null = null; +let loaderTimeoutId: NodeJS.Timeout | null = null; router.beforeEach((to, from) => { // Only show loading for actual route changes, not just query param changes if (to.path !== from.path) { const theme = useAppTheme(); - loader = $loading?.show({ - color: theme.value.primary.color, - }); + loaderTimeoutId = setTimeout(() => { + loader = $loading?.show({ + color: theme.value.primary.color, + }); + }, 350); } }); router.afterEach(() => { + if (loaderTimeoutId) { + clearTimeout(loaderTimeoutId); + loaderTimeoutId = null; + } if (loader) { loader.hide(); loader = null;