update 401 handler

This commit is contained in:
AceDataCloud committed 2023-01-26 12:50:26 +08:00
1 parent 396b77406d
commit 98a7532235
2 files changed
+10 -10

No files matched your search

+3 -4
View File
@@ -100,9 +100,7 @@ export default defineComponent({
deep: true
}
},
mounted() {
this.getApplications();
},
mounted() {},
methods: {
urlJoin,
getApplications() {
@@ -112,7 +110,8 @@ export default defineComponent({
})
.then(({ data: data }: { data: IApplicationListResponse }) => {
this.applications = data.items;
});
})
.catch((error) => {});
}
}
});
+7 -6
View File
@@ -1,4 +1,4 @@
import router, { ROUTE_INDEX } from '@/router';
import router, { ROUTE_AUTH_LOGIN, ROUTE_INDEX } from '@/router';
import store from '@/store';
import axios, { AxiosInstance } from 'axios';
import { getCookie } from 'typescript-cookie';
@@ -26,11 +26,12 @@ httpClient.interceptors.response.use(
(error) => {
if (error?.response?.status === 401) {
store.dispatch('resetAuth');
setTimeout(() => {
router.push({
name: ROUTE_INDEX
});
}, 1000);
router.push({
name: ROUTE_AUTH_LOGIN,
query: {
redirect: router?.currentRoute?.value?.path
}
});
}
return Promise.reject(error);
}