diff --git a/_web/src/store/modules/app.js b/_web/src/store/modules/app.js index 373a97eb..6d49e58b 100644 --- a/_web/src/store/modules/app.js +++ b/_web/src/store/modules/app.js @@ -24,7 +24,8 @@ const app = { autoHideHeader: false, color: null, weak: false, - multiTab: true + multiTab: true, + hasError: false }, mutations: { SET_SIDEBAR_TYPE: (state, type) => { @@ -74,6 +75,9 @@ const app = { TOGGLE_MULTI_TAB: (state, bool) => { Vue.ls.set(DEFAULT_MULTI_TAB, bool) state.multiTab = bool + }, + SET_HAS_ERROR: (state, bool) => { + state.hasError = bool } }, actions: { @@ -115,6 +119,9 @@ const app = { }, ToggleMultiTab ({ commit }, bool) { commit('TOGGLE_MULTI_TAB', bool) + }, + SetHasError ({ commit }, bool) { + commit('SET_HAS_ERROR', bool) } } } diff --git a/_web/src/utils/request.js b/_web/src/utils/request.js index b59a59e8..d4989467 100644 --- a/_web/src/utils/request.js +++ b/_web/src/utils/request.js @@ -1,6 +1,7 @@ import Vue from 'vue' import axios from 'axios' import store from '@/store' +// import router from './router' import { message, Modal, notification } from 'ant-design-vue' /// es/notification import { VueAxios } from './axios' import { ACCESS_TOKEN } from '@/store/mutation-types' @@ -62,23 +63,28 @@ service.interceptors.response.use((response) => { if (response.request.responseType === 'blob') { return response } + const resData = response.data const code = response.data.code - if (code === 1011006 || code === 1011007 || code === 1011008 || code === 1011009) { - Modal.error({ - title: '提示:', - content: response.data.message, - okText: '重新登录', - onOk: () => { - Vue.ls.remove(ACCESS_TOKEN) - window.location.reload() - } - }) - } else if (code === 1013002 || code === 1016002 || code === 1015002) { - message.error(response.data.message) - return response.data - } else { - return response.data + if (!store.state.app.hasError) { + if (code === 1011006 || code === 1011007 || code === 1011008 || code === 1011009) { + Modal.error({ + title: '提示:', + content: resData.message, + okText: '重新登录', + onOk: () => { + Vue.ls.remove(ACCESS_TOKEN) + store.dispatch('SetHasError', false) + window.location.reload() + } + }) + store.dispatch('SetHasError', true) + } + if (code === 1013002 || code === 1016002 || code === 1015002) { + message.error(response.data.message) + return response.data + } } + return resData }, err) const installer = {