|
@@ -1,7 +1,7 @@ |
|
|
/* |
|
|
/* |
|
|
* @Date: 2021-12-08 15:59:46 |
|
|
* @Date: 2021-12-08 15:59:46 |
|
|
* @LastEditors: JinxuChen |
|
|
* @LastEditors: JinxuChen |
|
|
* @LastEditTime: 2022-01-10 09:41:58 |
|
|
|
|
|
|
|
|
* @LastEditTime: 2022-01-11 14:25:43 |
|
|
* @FilePath: \GpsCardAdmin\src\utils\request.js |
|
|
* @FilePath: \GpsCardAdmin\src\utils\request.js |
|
|
* @description: |
|
|
* @description: |
|
|
*/ |
|
|
*/ |
|
@@ -55,23 +55,14 @@ service.interceptors.response.use( |
|
|
// if the custom code is not 20000, it is judged as an error. |
|
|
// if the custom code is not 20000, it is judged as an error. |
|
|
if (res.code !== 0) { |
|
|
if (res.code !== 0) { |
|
|
Message({ |
|
|
Message({ |
|
|
message: res.message || 'Error', |
|
|
|
|
|
|
|
|
message: res.message || '出错了,请联系管理员!', |
|
|
type: 'error', |
|
|
type: 'error', |
|
|
duration: 5 * 1000 |
|
|
|
|
|
|
|
|
duration: 3 * 1000 |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
// 106 token验证过期; |
|
|
// 106 token验证过期; |
|
|
if (res.code === 106) { |
|
|
|
|
|
|
|
|
return Promise.reject(new Error(res.message)) |
|
|
|
|
|
} else if (res.code === 106) { |
|
|
// to re-login |
|
|
// to re-login |
|
|
/* MessageBox.confirm('登录过期,是否重新登录?', { |
|
|
|
|
|
confirmButtonText: '确认', |
|
|
|
|
|
cancelButtonText: '取消', |
|
|
|
|
|
type: 'warning' |
|
|
|
|
|
}).then(() => { |
|
|
|
|
|
store.dispatch('user/resetToken').then(() => { |
|
|
|
|
|
location.reload() |
|
|
|
|
|
}) |
|
|
|
|
|
}) */ |
|
|
|
|
|
setTimeout(() => { |
|
|
setTimeout(() => { |
|
|
store.dispatch('user/resetToken').then(() => { |
|
|
store.dispatch('user/resetToken').then(() => { |
|
|
Message({ |
|
|
Message({ |
|
@@ -83,9 +74,8 @@ service.interceptors.response.use( |
|
|
}) |
|
|
}) |
|
|
}, 1500) |
|
|
}, 1500) |
|
|
return Promise.reject(new Error('token过期,请重新登录')) |
|
|
return Promise.reject(new Error('token过期,请重新登录')) |
|
|
} |
|
|
|
|
|
/* return Promise.reject(new Error(res.message)) */ |
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
return res |
|
|
return res |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
@@ -94,7 +84,7 @@ service.interceptors.response.use( |
|
|
Message({ |
|
|
Message({ |
|
|
message: error.message, |
|
|
message: error.message, |
|
|
type: 'error', |
|
|
type: 'error', |
|
|
duration: 5 * 1000 |
|
|
|
|
|
|
|
|
duration: 3 * 1000 |
|
|
}) |
|
|
}) |
|
|
/* return Promise.reject(error) */ |
|
|
/* return Promise.reject(error) */ |
|
|
} |
|
|
} |
|
|