Compare commits
2 Commits
aff45d11be
...
ce2f5c2f13
Author | SHA1 | Date |
---|---|---|
|
ce2f5c2f13 | |
|
e043c1b5fe |
|
@ -5,6 +5,7 @@ import { useUserStore } from '@/store';
|
|||
import { getToken,getRefreshToken } from '@/utils/auth';
|
||||
|
||||
export interface HttpResponse<T = unknown> {
|
||||
message: string;
|
||||
status: number;
|
||||
msg: string;
|
||||
code: number;
|
||||
|
@ -45,26 +46,27 @@ axios.interceptors.response.use(
|
|||
content: res.msg || res.message || 'Error',
|
||||
duration: 5 * 1000,
|
||||
});
|
||||
console.log(response.status)
|
||||
// 50008: Illegal token; 50012: Other clients logged in; 50014: Token expired;
|
||||
if (
|
||||
[50008, 50012, 50014,401].includes(res.code) &&
|
||||
response.config.url !== '/api/user/info'
|
||||
) {
|
||||
Modal.error({
|
||||
title: 'Confirm logout',
|
||||
content:
|
||||
'You have been logged out, you can cancel to stay on this page, or log in again',
|
||||
okText: 'Re-Login',
|
||||
async onOk() {
|
||||
const userStore = useUserStore();
|
||||
// console.log(response.status)
|
||||
// // 50008: Illegal token; 50012: Other clients logged in; 50014: Token expired;
|
||||
// if (
|
||||
// [50008, 50012, 50014,401].includes(res.code) &&
|
||||
// response.config.url !== '/api/user/info'
|
||||
// ) {
|
||||
// Modal.error({
|
||||
// title: 'Confirm logout',
|
||||
// content:
|
||||
// 'You have been logged out, you can cancel to stay on this page, or log in again',
|
||||
// okText: 'Re-Login',
|
||||
// async onOk() {
|
||||
// const userStore = useUserStore();
|
||||
|
||||
await userStore.logout();
|
||||
window.location.reload();
|
||||
},
|
||||
});
|
||||
}
|
||||
return Promise.reject(new Error(res.msg || 'Error'));
|
||||
// await userStore.logout();
|
||||
// window.location.reload();
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
// return Promise.reject(new Error(res.msg || 'Error'));
|
||||
return res
|
||||
}
|
||||
return res;
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue