Fixed redirect when offline
This commit is contained in:
parent
50f1f028eb
commit
d54b398c14
|
@ -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')
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue