diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtract.java b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtract.java
index babad81943..2dbd7e542e 100644
--- a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtract.java
+++ b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtract.java
@@ -97,7 +97,11 @@ public class MsExtract extends MsTestElement {
extractor.setMatchNumber(-1);
}
// $1$提取 JSON 响应中的第一个匹配项 $0$用于提取整个 JSON 响应
- extractor.setTemplate("$0$");
+ if (StringUtils.isNotEmpty(extractRegex.getTemplate())) {
+ extractor.setTemplate(extractRegex.getTemplate());
+ } else {
+ extractor.setTemplate("$1$");
+ }
extract.add(extractor.getRefName());
return extractor;
diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtractRegex.java b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtractRegex.java
index bb5782d066..a7cf11b169 100644
--- a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtractRegex.java
+++ b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtractRegex.java
@@ -7,7 +7,7 @@ import lombok.EqualsAndHashCode;
@Data
public class MsExtractRegex extends MsExtractCommon {
private String useHeaders;
-
+ private String template;
public MsExtractRegex() {
setType(MsExtractType.REGEX);
}
diff --git a/api-test/frontend/src/business/definition/components/extract/ApiExtractCommon.vue b/api-test/frontend/src/business/definition/components/extract/ApiExtractCommon.vue
index 1c8004d087..a18482fd3a 100644
--- a/api-test/frontend/src/business/definition/components/extract/ApiExtractCommon.vue
+++ b/api-test/frontend/src/business/definition/components/extract/ApiExtractCommon.vue
@@ -31,7 +31,15 @@
size="small"
show-word-limit
:placeholder="expression"
- @click.native="savePreParams(common.variable)" />
+ @click.native="savePreParams(common.variable)"
+ style="width: 70%" />
+
+
@@ -104,10 +112,21 @@ export default {
{ label: 'Response Code', value: 'code' },
{ label: 'Response Message', value: 'message' },
],
+ restaurants: [
+ { value: '$0$', id: '$0$' },
+ { value: '$1$', id: '$1$' },
+ ],
};
},
-
+ created() {
+ if (!this.common.template) {
+ this.$set(this.common, 'template', '$1$');
+ }
+ },
methods: {
+ querySearch(queryString, cb) {
+ cb(this.restaurants);
+ },
add() {
this.common.type = this.extractType;
this.list.push(new ExtractCommon(this.extractType, this.common));