Compare commits

..

No commits in common. "7e7e374e382b1b505dff808da3852743830f783c" and "31b1b1e3b6d00a871553ed6f40f5b3ebe47df25d" have entirely different histories.

3 changed files with 38 additions and 59 deletions

View File

@ -7,11 +7,10 @@ export function login(data) {
data
})
}
export function loginOut(params) {
export function loginOut() {
return request({
url: `/User/loginOut`,
method: 'get',
params
method: 'get'
})
}
export function getAllDictionary() {

View File

@ -181,10 +181,8 @@ const actions = {
// user logout
async logout({ commit, state }) {
try {
await loginOut()
removeToken() // must remove token first
await loginOut({
Userd: zzSessionStorage.getItem('userId')
})
resetRouter()
removeName()
zzSessionStorage.clear()

View File

@ -49,13 +49,13 @@ service.interceptors.request.use(
}
)
let timer = null;
let time = 1000;
var isConfirm = true
service.interceptors.response.use(
response => {
const res = response.data
if (res.IsSuccess) {
isConfirm = true
return Promise.resolve(res)
} else if (res.IsSuccess === false) {
if (res.Code !== 5) {
@ -105,11 +105,11 @@ service.interceptors.response.use(
if (error.response.status === 401) {
if (store.getters.token) {
if(message !== ''){
setTimer({
Message({
message: message,
type: 'warning',
showClose: true
}, 'message')
})
}
store.dispatch('user/logout').then(() => {
router.push(`/login`)
@ -118,52 +118,34 @@ service.interceptors.response.use(
this.$updateDictionary()
})
} else {
setTimer({
Message({
message: store.state.lang.language === 'en'? 'You are not authorized to access the interface' : '您无权访问接口',
type: 'warning',
showClose: true
}, 'message')
})
}
} else {
if (message !== '') {
setTimer([message, store.state.lang.language === 'en' ? 'Warning' : '警告', {
if(message !== '' && isConfirm){
MessageBox.confirm(message, store.state.lang.language === 'en'? 'Warning' : '警告', {
type: 'warning',
showCancelButton: false,
callback: action => {}
}], 'confirm')
})
}
}
}
if (!window.navigator.onLine) {
setTimer(
[store.state.lang.language === 'en' ? 'Please check your networkand try again later' : '请检查网络,稍后重试!', store.state.lang.language === 'en' ? 'Warning' : '警告', {
if (!window.navigator.onLine && isConfirm) {
MessageBox.confirm(store.state.lang.language === 'en'? 'Please check your networkand try again later' : '请检查网络,稍后重试!', store.state.lang.language === 'en'? 'Warning' : '警告', {
type: 'warning',
showCancelButton: false,
callback: action => {}
}], "confirm"
)
})
isConfirm = false
}
return Promise.reject(new Error(message || 'Error'))
}
)
const setTimer = (obj, type) => {
if (timer) {
clearTimeout(timer);
timer = null;
}
timer = setTimeout(() => {
if (type === 'message') {
Message(obj)
}
if (type === 'confirm') {
MessageBox.confirm(...obj)
}
clearTimeout(timer);
timer = null;
}, time)
}