Fixed redirect when offline

This commit is contained in:
Ferdinand Thiessen 2021-02-04 02:43:53 +01:00
parent 50f1f028eb
commit d54b398c14
2 changed files with 9 additions and 3 deletions

View File

@ -40,9 +40,13 @@ export default boot<UserSessionState>(({ 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 = <string>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')

View File

@ -46,8 +46,10 @@ export default defineComponent({
const ival = setInterval(() => {
reload.value -= 1;
if (reload.value === 0) {
const path = <string | null>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: <string>path } : { name: 'login' });
}
}, 1000);
onUnmounted(() => clearInterval(ival));