diff --git a/magic-api/src/main/java/org/ssssssss/magicapi/controller/MagicController.java b/magic-api/src/main/java/org/ssssssss/magicapi/controller/MagicController.java index 0226b83e..ff879bad 100644 --- a/magic-api/src/main/java/org/ssssssss/magicapi/controller/MagicController.java +++ b/magic-api/src/main/java/org/ssssssss/magicapi/controller/MagicController.java @@ -97,6 +97,6 @@ public class MagicController implements JsonCodeConstants { @ExceptionHandler(MagicLoginException.class) @ResponseBody public JsonBean invalidLogin(MagicLoginException exception) { - return new JsonBean<>(-1, exception.getMessage()); + return new JsonBean<>(401, exception.getMessage()); } } diff --git a/magic-editor/src/console/src/api/request.js b/magic-editor/src/console/src/api/request.js index 476f8d92..628e1e5e 100644 --- a/magic-editor/src/console/src/api/request.js +++ b/magic-editor/src/console/src/api/request.js @@ -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 diff --git a/magic-editor/src/console/src/components/editor/magic-script-editor.vue b/magic-editor/src/console/src/components/editor/magic-script-editor.vue index 2eedf955..71e52f13 100644 --- a/magic-editor/src/console/src/components/editor/magic-script-editor.vue +++ b/magic-editor/src/console/src/components/editor/magic-script-editor.vue @@ -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() } diff --git a/magic-editor/src/console/src/components/magic-editor.vue b/magic-editor/src/console/src/components/magic-editor.vue index bfccf49a..2c7165c1 100644 --- a/magic-editor/src/console/src/components/magic-editor.vue +++ b/magic-editor/src/console/src/components/magic-editor.vue @@ -196,6 +196,7 @@ export default { } }) bus.$on('logout', () => this.showLogin = true) + bus.$on('showLogin', () => this.showLogin = true) this.open() }, destroyed() {