fix(模块树组件): #1006836 【接口定义】新建子模块会自动折叠

【【接口定义】新建子模块会自动折叠】https://www.tapd.cn/55049933/bugtrace/bugs/view?bug_id=1155049933001006836
This commit is contained in:
song-tianyang 2021-09-22 18:07:51 +08:00 committed by song-tianyang
parent 6ad01bb07e
commit f0bc12c98f
2 changed files with 7 additions and 5 deletions

View File

@ -17,6 +17,7 @@ import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.XMLUtils; import io.metersphere.commons.utils.XMLUtils;
import io.swagger.models.Model; import io.swagger.models.Model;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -46,11 +47,9 @@ public class HarParser extends HarAbstractParser {
MSException.throwException(e.getMessage()); MSException.throwException(e.getMessage());
LogUtil.error(e.getMessage(), e); LogUtil.error(e.getMessage(), e);
} }
if (ObjectUtils.isEmpty(har)) { if (ObjectUtils.isEmpty(har)) {
MSException.throwException("解析失败,请确认选择的是 Har 格式!"); MSException.throwException("解析失败,请确认选择的是 Har 格式!");
} }
ApiDefinitionImport definitionImport = new ApiDefinitionImport(); ApiDefinitionImport definitionImport = new ApiDefinitionImport();
this.projectId = request.getProjectId(); this.projectId = request.getProjectId();
definitionImport.setData(parseRequests(har, request)); definitionImport.setData(parseRequests(har, request));
@ -213,9 +212,11 @@ public class HarParser extends HarAbstractParser {
} else if (contentType.startsWith(org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE)) { } else if (contentType.startsWith(org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE)) {
contentType = org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE; contentType = org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE;
List<HarPostParam> postParams = content.params; List<HarPostParam> postParams = content.params;
for (HarPostParam postParam : postParams) { if(CollectionUtils.isNotEmpty(postParams)){
KeyValue kv = new KeyValue(postParam.name,postParam.value); for (HarPostParam postParam : postParams) {
body.getKvs().add(kv); KeyValue kv = new KeyValue(postParam.name,postParam.value);
body.getKvs().add(kv);
}
} }
} else if (contentType.startsWith(org.springframework.http.MediaType.APPLICATION_JSON_VALUE)) { } else if (contentType.startsWith(org.springframework.http.MediaType.APPLICATION_JSON_VALUE)) {
contentType = org.springframework.http.MediaType.APPLICATION_JSON_VALUE; contentType = org.springframework.http.MediaType.APPLICATION_JSON_VALUE;

View File

@ -327,6 +327,7 @@ export default {
if (param.type === 'edit') { if (param.type === 'edit') {
this.$emit('edit', param); this.$emit('edit', param);
} else { } else {
this.expandedNode.push(param.parentId);
this.$emit('add', param); this.$emit('add', param);
} }
this.$set(data, 'isEdit', false); this.$set(data, 'isEdit', false);