【优化】优化多次弹窗

This commit is contained in:
小诺 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, autoHideHeader: false,
color: null, color: null,
weak: false, weak: false,
multiTab: true multiTab: true,
hasError: false
}, },
mutations: { mutations: {
SET_SIDEBAR_TYPE: (state, type) => { SET_SIDEBAR_TYPE: (state, type) => {
@ -74,6 +75,9 @@ const app = {
TOGGLE_MULTI_TAB: (state, bool) => { TOGGLE_MULTI_TAB: (state, bool) => {
Vue.ls.set(DEFAULT_MULTI_TAB, bool) Vue.ls.set(DEFAULT_MULTI_TAB, bool)
state.multiTab = bool state.multiTab = bool
},
SET_HAS_ERROR: (state, bool) => {
state.hasError = bool
} }
}, },
actions: { actions: {
@ -115,6 +119,9 @@ const app = {
}, },
ToggleMultiTab ({ commit }, bool) { ToggleMultiTab ({ commit }, bool) {
commit('TOGGLE_MULTI_TAB', 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 Vue from 'vue'
import axios from 'axios' import axios from 'axios'
import store from '@/store' import store from '@/store'
// import router from './router'
import { message, Modal, notification } from 'ant-design-vue' /// es/notification import { message, Modal, notification } from 'ant-design-vue' /// es/notification
import { VueAxios } from './axios' import { VueAxios } from './axios'
import { ACCESS_TOKEN } from '@/store/mutation-types' import { ACCESS_TOKEN } from '@/store/mutation-types'
@ -62,23 +63,28 @@ service.interceptors.response.use((response) => {
if (response.request.responseType === 'blob') { if (response.request.responseType === 'blob') {
return response return response
} }
const resData = response.data
const code = response.data.code const code = response.data.code
if (code === 1011006 || code === 1011007 || code === 1011008 || code === 1011009) { if (!store.state.app.hasError) {
Modal.error({ if (code === 1011006 || code === 1011007 || code === 1011008 || code === 1011009) {
title: '提示', Modal.error({
content: response.data.message, title: '提示',
okText: '重新登录', content: resData.message,
onOk: () => { okText: '重新登录',
Vue.ls.remove(ACCESS_TOKEN) onOk: () => {
window.location.reload() Vue.ls.remove(ACCESS_TOKEN)
} store.dispatch('SetHasError', false)
}) window.location.reload()
} else if (code === 1013002 || code === 1016002 || code === 1015002) { }
message.error(response.data.message) })
return response.data store.dispatch('SetHasError', true)
} else { }
return response.data if (code === 1013002 || code === 1016002 || code === 1015002) {
message.error(response.data.message)
return response.data
}
} }
return resData
}, err) }, err)
const installer = { const installer = {