代码调整
This commit is contained in:
parent
141d351794
commit
f4051c5190
@ -66,7 +66,7 @@ export class ApiError {
|
|||||||
// "export default () => {}" function below (which runs individually
|
// "export default () => {}" function below (which runs individually
|
||||||
// for each client)
|
// for each client)
|
||||||
const api = axios.create({ baseURL: getHttpBase() });
|
const api = axios.create({ baseURL: getHttpBase() });
|
||||||
|
let isOpenDialog = false; // 认证弹窗是否打开
|
||||||
export default boot(({ app, router }) => {
|
export default boot(({ app, router }) => {
|
||||||
// for use inside Vue files (Options API) through this.$axios and this.$api
|
// for use inside Vue files (Options API) through this.$axios and this.$api
|
||||||
|
|
||||||
@ -86,14 +86,20 @@ export default boot(({ app, router }) => {
|
|||||||
return response;
|
return response;
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
if (err.response && err.response.status === 401) {
|
if (err.response && err.response.status === 401 && !isOpenDialog) {
|
||||||
|
isOpenDialog = true;
|
||||||
Dialog.create({
|
Dialog.create({
|
||||||
title: '认证失败',
|
title: '认证失败',
|
||||||
message: '认证失败或登录超时,请重新登录',
|
message: '认证失败或登录超时,请重新登录',
|
||||||
persistent: true,
|
persistent: true,
|
||||||
}).onOk(() => {
|
})
|
||||||
router.push({ name: 'login' });
|
.onOk(() => {
|
||||||
});
|
router.push({ name: 'login' });
|
||||||
|
isOpenDialog = false;
|
||||||
|
})
|
||||||
|
.onCancel(() => {
|
||||||
|
isOpenDialog = false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return Promise.reject(ApiError.from(err));
|
return Promise.reject(ApiError.from(err));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user