fix: API文档分享链接失效的问题

API文档分享链接失效的问题
This commit is contained in:
song.tianyang 2021-03-23 21:27:19 +08:00
parent 691cf5a380
commit 47ec0a77da
4 changed files with 33 additions and 14 deletions

View File

@ -68,24 +68,36 @@ public class HarParser extends HarAbstractParser {
harEntryList = har.log.entries;
}
List<String> savedUrl = new ArrayList<>();
for (HarEntry entry : harEntryList) {
HarRequest harRequest = entry.request;
String url = harRequest.url;
if(url == null){
continue;
}
try {
url = URLDecoder.decode(url,"UTF-8");
}catch (Exception e){
}
if(savedUrl.contains(harRequest.url)){
continue;
}else {
savedUrl.add(harRequest.url);
}
//默认取路径的最后一块
String reqName = "";
if (harRequest.url != null) {
String[] nameArr = harRequest.url.split("/");
String[] nameArr = url.split("/");
reqName = nameArr[nameArr.length - 1];
//然后进行转码解码
try {
reqName = URLDecoder.decode(reqName,"UTF-8");
}catch (Exception e){
}
}
if (harRequest != null) {
MsHTTPSamplerProxy request = super.buildRequest(reqName, harRequest.url, harRequest.method);
ApiDefinitionWithBLOBs apiDefinition = super.buildApiDefinition(request.getId(), reqName, harRequest.url, harRequest.method, importRequest);
MsHTTPSamplerProxy request = super.buildRequest(reqName, url, harRequest.method);
ApiDefinitionWithBLOBs apiDefinition = super.buildApiDefinition(request.getId(), reqName, url, harRequest.method, importRequest);
parseParameters(harRequest, request);
parseRequestBody(harRequest, request.getBody());
addBodyHeader(request);

View File

@ -372,7 +372,7 @@ public class ApiDocumentService {
ApiDocumentShareDTO returnDTO = new ApiDocumentShareDTO();
if (!StringUtils.isEmpty(apiShare.getShareApiId())) {
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
String url = "/#/apiDocumentInfo?documentId=" + apiShare.getId();
String url = "?" + apiShare.getId();
returnDTO.setId(apiShare.getId());
returnDTO.setShareUrl(url);
}

@ -1 +1 @@
Subproject commit bc5735a2eb796640bde400ae6cafca6229672905
Subproject commit 93adcdc32a98967ddff208bf5f8868c5e3c063da

View File

@ -40,10 +40,17 @@ export default {
},
methods: {
getUrlParam(){
let queryParams =this.$route.query;
let documentIdParam = queryParams['documentId'];
this.documentId = queryParams['documentId'];
return documentIdParam;
let herfUrl = window.location.href;
if(herfUrl.indexOf("?") > 0){
let paramArr = herfUrl.split("?");
if(paramArr.length > 1){
let documentId = paramArr[1];
if(documentId.indexOf("#") > 0){
documentId = documentId.split("#")[0];
}
this.documentId = documentId;
}
}
},
selectDocumentInfo(){
this.getUrlParam();