From d54b398c146b8093eefa1dc70d3f3b3fbecebb4d Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Thu, 4 Feb 2021 02:43:53 +0100 Subject: [PATCH] Fixed redirect when offline --- src/boot/axios.ts | 6 +++++- src/pages/Offline.vue | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) 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));