fix(接口测试):引用环境url显示问题

This commit is contained in:
chenjianxing 2020-09-17 11:34:17 +08:00
parent dc41ddc683
commit 5ef0f5a629
2 changed files with 4 additions and 3 deletions

View File

@ -9,7 +9,7 @@
<el-select :disabled="isReadOnly" v-model="scenario.environmentId" class="environment-select" <el-select :disabled="isReadOnly" v-model="scenario.environmentId" class="environment-select"
@change="environmentChange" clearable> @change="environmentChange" clearable>
<el-option v-for="(environment, index) in environments" :key="index" <el-option v-for="(environment, index) in environments" :key="index"
:label="environment.name + ': ' + environment.protocol + '://' + environment.socket" :label="environment.name + (environment.config.httpConfig.socket ? (': ' + environment.config.httpConfig.protocol + '://' + environment.config.httpConfig.socket) : '')"
:value="environment.id"/> :value="environment.id"/>
<el-button class="environment-button" size="mini" type="primary" @click="openEnvironmentConfig"> <el-button class="environment-button" size="mini" type="primary" @click="openEnvironmentConfig">
{{ $t('api_test.environment.environment_config') }} {{ $t('api_test.environment.environment_config') }}

View File

@ -148,7 +148,7 @@ export default {
if (!this.request.path) return; if (!this.request.path) return;
let url = this.getURL(this.displayUrl); let url = this.getURL(this.displayUrl);
let urlStr = url.origin + url.pathname; let urlStr = url.origin + url.pathname;
let envUrl = this.request.environment.protocol + '://' + this.request.environment.socket; let envUrl = this.request.environment.config.httpConfig.protocol + '://' + this.request.environment.config.httpConfig.socket;
this.request.path = decodeURIComponent(urlStr.substring(envUrl.length, urlStr.length)); this.request.path = decodeURIComponent(urlStr.substring(envUrl.length, urlStr.length));
}, },
getURL(urlStr) { getURL(urlStr) {
@ -194,7 +194,8 @@ export default {
return this.request.method !== "GET"; return this.request.method !== "GET";
}, },
displayUrl() { displayUrl() {
return this.request.environment ? this.request.environment.protocol + '://' + this.request.environment.socket + (this.request.path ? this.request.path : '') : ''; return this.request.environment.config.httpConfig.socket ? this.request.environment.config.httpConfig.protocol + '://'
+ this.request.environment.config.httpConfig.socket + (this.request.path ? this.request.path : '') : '';
} }
} }
} }