diff --git a/frontend/src/business/components/api/test/ApiTestConfig.vue b/frontend/src/business/components/api/test/ApiTestConfig.vue
index 2605d077fd..7627a17a35 100644
--- a/frontend/src/business/components/api/test/ApiTestConfig.vue
+++ b/frontend/src/business/components/api/test/ApiTestConfig.vue
@@ -39,6 +39,9 @@
{{$t('api_test.create_performance_test')}}
+
+ {{$t('api_test.export_config')}}
+
@@ -57,7 +60,7 @@
import {Test} from "./model/ScenarioModel"
import MsApiReportStatus from "../report/ApiReportStatus";
import MsApiReportDialog from "./ApiReportDialog";
- import {checkoutTestManagerOrTestUser} from "../../../../common/js/utils";
+ import {checkoutTestManagerOrTestUser, downloadFile} from "../../../../common/js/utils";
export default {
name: "MsApiTestConfig",
@@ -201,6 +204,9 @@
path: "/performance/test/create"
})
break;
+ case "export":
+ downloadFile(this.test.name + ".json", JSON.stringify(this.test));
+ break;
}
}
},
diff --git a/frontend/src/common/js/utils.js b/frontend/src/common/js/utils.js
index 918b4929bd..525d051775 100644
--- a/frontend/src/common/js/utils.js
+++ b/frontend/src/common/js/utils.js
@@ -125,7 +125,7 @@ export function _filter(filters, condition) {
if (!condition.filters) {
condition.filters = {};
}
- for(let filter in filters) {
+ for (let filter in filters) {
if (filters[filter] && filters[filter].length > 0) {
condition.filters[filter] = filters[filter];
} else {
@@ -157,3 +157,19 @@ export function _sort(column, condition) {
condition.orders.push({name: column.prop, type: column.order});
}
}
+
+export function downloadFile(name, content) {
+ const blob = new Blob([content]);
+ if ("download" in document.createElement("a")) {
+ // 非IE下载
+ // chrome/firefox
+ let aTag = document.createElement('a');
+ aTag.download = name;
+ aTag.href = URL.createObjectURL(blob);
+ aTag.click();
+ URL.revokeObjectURL(aTag.href)
+ } else {
+ // IE10+下载
+ navigator.msSaveBlob(blob, name)
+ }
+}
diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js
index e39c96ac8f..371a083dad 100644
--- a/frontend/src/i18n/en-US.js
+++ b/frontend/src/i18n/en-US.js
@@ -283,6 +283,7 @@ export default {
key: "Key",
value: "Value",
create_performance_test: "Create Performance Test",
+ export_config: "Export Configuration",
scenario: {
config: "Scenario Config",
input_name: "Please enter the scenario name",
diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js
index 1d98b815b9..eb9616bb20 100644
--- a/frontend/src/i18n/zh-CN.js
+++ b/frontend/src/i18n/zh-CN.js
@@ -282,6 +282,7 @@ export default {
key: "键",
value: "值",
create_performance_test: "创建性能测试",
+ export_config: "导出配置",
scenario: {
config: "场景配置",
input_name: "请输入场景名称",
diff --git a/frontend/src/i18n/zh-TW.js b/frontend/src/i18n/zh-TW.js
index 4b4b99cb5a..eab2504f44 100644
--- a/frontend/src/i18n/zh-TW.js
+++ b/frontend/src/i18n/zh-TW.js
@@ -280,6 +280,7 @@ export default {
key: "鍵",
value: "值",
create_performance_test: "創建性能測試",
+ export_config: "匯出配寘",
scenario: {
creator: "創建人",
config: "場景配寘",