|
@@ -22,9 +22,9 @@ service.interceptors.request.use(
|
|
|
delete config.headers['auth'];
|
|
|
const message = '缺少凭证,请重新登录!';
|
|
|
let deviceid = localStorage.getItem('deviceid');
|
|
|
- if ((router.currentRoute.value.path == '/gesture') || (deviceid && router.currentRoute.value.path != '/login/qrcode')) {
|
|
|
+ if (router.currentRoute.value.path == '/gesture' || (deviceid && router.currentRoute.value.path != '/login/qrcode')) {
|
|
|
router.push('/login/qrcode');
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
router.push('/login');
|
|
|
}
|
|
|
localStorage.clear();
|
|
@@ -59,17 +59,20 @@ service.interceptors.request.use(
|
|
|
service.interceptors.response.use(
|
|
|
(res: AxiosResponse) => {
|
|
|
const code = res.data.code;
|
|
|
+ const status = res.data.status;
|
|
|
const message = res.data.message;
|
|
|
if (code === 401) {
|
|
|
let deviceid = localStorage.getItem('deviceid');
|
|
|
- if ((router.currentRoute.value.path == '/gesture') || (deviceid && router.currentRoute.value.path != '/login/qrcode')) {
|
|
|
+ if (router.currentRoute.value.path == '/gesture' || (deviceid && router.currentRoute.value.path != '/login/qrcode')) {
|
|
|
router.push('/login/qrcode');
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
router.push('/login');
|
|
|
}
|
|
|
localStorage.clear();
|
|
|
ElMessage({ message: message, type: 'error', duration: 5 * 1000 });
|
|
|
return Promise.reject('凭证已过期,请重新登录!');
|
|
|
+ } else if (status == 500) {
|
|
|
+ return Promise.reject(message);
|
|
|
} else {
|
|
|
return Promise.resolve(res.data);
|
|
|
}
|