diff --git a/src/boot/axios.ts b/src/boot/axios.ts index 99c8bd4..916a863 100644 --- a/src/boot/axios.ts +++ b/src/boot/axios.ts @@ -40,9 +40,13 @@ export default boot(({ app, store, router }) => { e.code === 'ECONNABORTED' || (e.response && e.response.status >= 502 && e.response.status <= 504) ) { + const current = router.currentRoute.value; + let next = current.path; + if ((current.name == 'login' || current.name == 'offline') && current.query.redirect) + next = current.query.redirect; return router.push({ name: 'offline', - query: { redirect: router.currentRoute.value.fullPath }, + query: { redirect: next }, }); } else if (e.response && e.response.status == 401) { if (router.currentRoute.value.name !== 'login') diff --git a/src/pages/Offline.vue b/src/pages/Offline.vue index 7ea6d2a..a425009 100644 --- a/src/pages/Offline.vue +++ b/src/pages/Offline.vue @@ -46,8 +46,10 @@ export default defineComponent({ const ival = setInterval(() => { reload.value -= 1; if (reload.value === 0) { - const path = router.currentRoute.value.query.redirect || '/login'; - void router.replace({ path: path }); + const path = router.currentRoute.value.query.redirect; + console.log('Offline: '); + console.log(path); + void router.replace(path ? { path: path } : { name: 'login' }); } }, 1000); onUnmounted(() => clearInterval(ival));