Compare commits

...

2 Commits

Author SHA1 Message Date
lingling ce2f5c2f13 Merge branch 'master' of https://git.shagain.club/shulang/webcons 2025-02-24 20:55:51 +08:00
lingling e043c1b5fe 完善错误 2025-02-24 20:54:41 +08:00
1 changed files with 21 additions and 19 deletions

View File

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