【优化】优化多次弹窗

pull/22/head v1.5.2
小诺 2021-05-05 00:26:57 +08:00 committed by 15099670051
parent 7116d314b5
commit a3570d1ecd
2 changed files with 29 additions and 16 deletions

View File

@ -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)
}
}
}

View File

@ -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 = {