mirror of
https://gitee.com/ssssssss-team/magic-api.git
synced 2026-06-09 18:32:16 +08:00
修复在使用过程中Token失效后未显示登录框的问题
This commit is contained in:
@@ -97,6 +97,6 @@ public class MagicController implements JsonCodeConstants {
|
||||
@ExceptionHandler(MagicLoginException.class)
|
||||
@ResponseBody
|
||||
public JsonBean<Void> invalidLogin(MagicLoginException exception) {
|
||||
return new JsonBean<>(-1, exception.getMessage());
|
||||
return new JsonBean<>(401, exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import axios from 'axios'
|
||||
import Qs from 'qs'
|
||||
import {modal} from '@/components/common/modal'
|
||||
import {replaceURL} from '@/scripts/utils.js'
|
||||
import contants from '@/scripts/contants.js'
|
||||
import bus from '@/scripts/bus.js'
|
||||
|
||||
const config = {
|
||||
// 请求路径
|
||||
@@ -139,14 +139,20 @@ class HttpRequest {
|
||||
}
|
||||
requestConfig.baseURL = config.baseURL
|
||||
let httpResponse = new HttpResponse()
|
||||
let successed = false;
|
||||
this.execute(requestConfig)
|
||||
.then(response => {
|
||||
let data = response.data
|
||||
if(data instanceof Blob){
|
||||
successed = true
|
||||
httpResponse.successHandle && httpResponse.successHandle(data, response)
|
||||
}else if (data.code === 1) {
|
||||
} else if (data.code === 1) {
|
||||
successed = true
|
||||
httpResponse.successHandle && httpResponse.successHandle(data.data, response)
|
||||
} else {
|
||||
if (data.code === 401) {
|
||||
bus.$emit('showLogin')
|
||||
}
|
||||
httpResponse.exceptionHandle && httpResponse.exceptionHandle(data.code, data.message, response)
|
||||
}
|
||||
})
|
||||
@@ -160,7 +166,7 @@ class HttpRequest {
|
||||
})
|
||||
.finally(() => {
|
||||
if (typeof httpResponse.endHandle === 'function') {
|
||||
httpResponse.endHandle()
|
||||
httpResponse.endHandle(successed)
|
||||
}
|
||||
})
|
||||
return httpResponse
|
||||
|
||||
@@ -474,7 +474,11 @@ export default {
|
||||
if (contants.AUTO_SAVE) {
|
||||
// 自动保存
|
||||
let resp = this.doSave()
|
||||
resp && resp.end(() => this.internalTest())
|
||||
resp && resp.end((successed) => {
|
||||
if (successed) {
|
||||
this.internalTest()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.internalTest()
|
||||
}
|
||||
|
||||
@@ -196,6 +196,7 @@ export default {
|
||||
}
|
||||
})
|
||||
bus.$on('logout', () => this.showLogin = true)
|
||||
bus.$on('showLogin', () => this.showLogin = true)
|
||||
this.open()
|
||||
},
|
||||
destroyed() {
|
||||
|
||||
Reference in New Issue
Block a user