diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue
index d06a8b0e95..cfebd0feb7 100644
--- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue
+++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue
@@ -5,7 +5,7 @@
-
+
{{ $t('commons.save') }}
@@ -119,7 +119,7 @@
:project-list="projectList" ref="envPopover"/>
- {{$t('api_test.request.debug')}}
+ {{$t('api_test.request.debug')}}
@@ -707,29 +707,29 @@
},
runDebug() {
/*触发执行操作*/
- // if (!this.currentEnvironmentId) {
- // this.$error(this.$t('api_test.environment.select_environment'));
- // return;
- // }
let sign = this.$refs.envPopover.checkEnv();
if (!sign) {
return;
}
this.$refs['currentScenario'].validate((valid) => {
if (valid) {
- this.editScenario();
- this.debugData = {
- id: this.currentScenario.id,
- name: this.currentScenario.name,
- type: "scenario",
- variables: this.currentScenario.variables,
- referenced: 'Created',
- enableCookieShare: this.enableCookieShare,
- headers: this.currentScenario.headers,
- environmentMap: this.projectEnvMap,
- hashTree: this.scenarioDefinition
- };
- this.reportId = getUUID().substring(0, 8);
+ Promise.all([
+ this.editScenario()]).then(val => {
+ if (val) {
+ this.debugData = {
+ id: this.currentScenario.id,
+ name: this.currentScenario.name,
+ type: "scenario",
+ variables: this.currentScenario.variables,
+ referenced: 'Created',
+ enableCookieShare: this.enableCookieShare,
+ headers: this.currentScenario.headers,
+ environmentMap: this.projectEnvMap,
+ hashTree: this.scenarioDefinition
+ };
+ this.reportId = getUUID().substring(0, 8);
+ }
+ });
}
})
},
@@ -884,24 +884,27 @@
return bodyUploadFiles;
},
editScenario() {
- document.getElementById("inputDelay").focus(); // 保存前在input框自动失焦,以免保存失败
- this.$refs['currentScenario'].validate((valid) => {
- if (valid) {
- this.setParameter();
- let bodyFiles = this.getBodyUploadFiles(this.currentScenario);
- this.$fileUpload(this.path, null, bodyFiles, this.currentScenario, response => {
- this.$success(this.$t('commons.save_success'));
- this.path = "/api/automation/update";
- if (response.data) {
- this.currentScenario.id = response.data.id;
- }
- if (this.currentScenario.tags instanceof String) {
- this.currentScenario.tags = JSON.parse(this.currentScenario.tags);
- }
- this.$emit('refresh', this.currentScenario);
- })
- }
- })
+ return new Promise((resolve, reject) => {
+ document.getElementById("inputDelay").focus(); // 保存前在input框自动失焦,以免保存失败
+ this.$refs['currentScenario'].validate((valid) => {
+ if (valid) {
+ this.setParameter();
+ let bodyFiles = this.getBodyUploadFiles(this.currentScenario);
+ this.$fileUpload(this.path, null, bodyFiles, this.currentScenario, response => {
+ this.$success(this.$t('commons.save_success'));
+ this.path = "/api/automation/update";
+ if (response.data) {
+ this.currentScenario.id = response.data.id;
+ }
+ if (this.currentScenario.tags instanceof String) {
+ this.currentScenario.tags = JSON.parse(this.currentScenario.tags);
+ }
+ this.$emit('refresh', this.currentScenario);
+ resolve();
+ })
+ }
+ })
+ });
},
getApiScenario() {
if (this.currentScenario.tags != undefined && !(this.currentScenario.tags instanceof Array)) {
diff --git a/frontend/src/business/main.js b/frontend/src/business/main.js
index 1b2c601312..3afcf3d9ca 100644
--- a/frontend/src/business/main.js
+++ b/frontend/src/business/main.js
@@ -22,8 +22,10 @@ import {left2RightDrag, bottom2TopDrag, right2LeftDrag} from "../common/js/direc
import JsonSchemaEditor from './components/common/json-schema/schema/index';
import JSONPathPicker from 'vue-jsonpath-picker';
import VueClipboard from 'vue-clipboard2'
+
Vue.use(JsonSchemaEditor);
import VuePapaParse from 'vue-papa-parse'
+
Vue.use(VuePapaParse)
Vue.config.productionTip = false;
@@ -56,6 +58,19 @@ Vue.directive('tester', tester);
Vue.directive('left-to-right-drag', left2RightDrag);
Vue.directive('right-to-left-drag', right2LeftDrag);
Vue.directive('bottom-to-top-drag', bottom2TopDrag);
+// 防止重复点击
+Vue.directive('preventReClick', {
+ inserted(el, binding) {
+ el.addEventListener('click', () => {
+ if (!el.disabled) {
+ el.disabled = true
+ setTimeout(() => {
+ el.disabled = false
+ }, binding.value || 2000)
+ }
+ })
+ }
+})
new Vue({
el: '#app',