refactor: 环境域名可以设置为DbeaseUrl
This commit is contained in:
parent
7cbb202309
commit
ff76a7e69d
|
@ -2,7 +2,7 @@
|
||||||
<el-dialog :title="$t('api_test.environment.environment_config')" :visible.sync="visible" class="environment-dialog"
|
<el-dialog :title="$t('api_test.environment.environment_config')" :visible.sync="visible" class="environment-dialog"
|
||||||
@close="close" append-to-body ref="environmentConfig">
|
@close="close" append-to-body ref="environmentConfig">
|
||||||
<el-container v-loading="result.loading">
|
<el-container v-loading="result.loading">
|
||||||
<ms-aside-item :title="$t('api_test.environment.environment_list')" :data="environments" :item-operators="environmentOperators" :add-fuc="addEnvironment"
|
<ms-aside-item :enable-aside-hidden="false" :title="$t('api_test.environment.environment_list')" :data="environments" :item-operators="environmentOperators" :add-fuc="addEnvironment"
|
||||||
:delete-fuc="deleteEnvironment" @itemSelected="environmentSelected" ref="environmentItems"/>
|
:delete-fuc="deleteEnvironment" @itemSelected="environmentSelected" ref="environmentItems"/>
|
||||||
<environment-edit :environment="currentEnvironment" ref="environmentEdit" @close="close"/>
|
<environment-edit :environment="currentEnvironment" ref="environmentEdit" @close="close"/>
|
||||||
</el-container>
|
</el-container>
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
import MsApiKeyValue from "../ApiKeyValue";
|
import MsApiKeyValue from "../ApiKeyValue";
|
||||||
import MsDialogFooter from "../../../../common/components/MsDialogFooter";
|
import MsDialogFooter from "../../../../common/components/MsDialogFooter";
|
||||||
import {REQUEST_HEADERS} from "../../../../../../common/js/constants";
|
import {REQUEST_HEADERS} from "../../../../../../common/js/constants";
|
||||||
|
import {KeyValue} from "../../model/ScenarioModel";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "EnvironmentEdit",
|
name: "EnvironmentEdit",
|
||||||
|
@ -110,39 +111,30 @@
|
||||||
},
|
},
|
||||||
validateSocket(socket) {
|
validateSocket(socket) {
|
||||||
if (!socket) return;
|
if (!socket) return;
|
||||||
let socketInfo = socket.split(":");
|
let urlStr = this.environment.protocol + '://' + socket;
|
||||||
if (socketInfo.length > 2) {
|
let url = {};
|
||||||
return false;
|
try {
|
||||||
|
url = new URL(urlStr);
|
||||||
|
} catch (e) {
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
let host = socketInfo[0];
|
|
||||||
let port = socketInfo[1];
|
this.environment.port = url.port;
|
||||||
if (!this.validateHost(host) || !(port == undefined || this.validatePort(port))) {
|
this.environment.domain = decodeURIComponent(url.hostname);
|
||||||
return false;
|
if (url.port) {
|
||||||
|
this.environment.socket = this.environment.domain + ':' + url.port + url.pathname;
|
||||||
|
} else {
|
||||||
|
this.environment.socket = this.environment.domain + url.pathname;
|
||||||
}
|
}
|
||||||
this.environment.domain = host;
|
|
||||||
this.environment.port = port;
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
validateHost(host) {
|
|
||||||
let hostReg = /^(?=^.{3,255}$)[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$/;
|
|
||||||
if (hostReg.test(host) || host === 'localhost') {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
validatePort(port) {
|
|
||||||
let portReg = /^[1-9]\d*$/;
|
|
||||||
if (portReg.test(port) && 1 <= 1*port && 1*port <= 65535){
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
cancel() {
|
cancel() {
|
||||||
this.$emit('close');
|
this.$emit('close');
|
||||||
},
|
},
|
||||||
clearValidate() {
|
clearValidate() {
|
||||||
this.$refs["from"].clearValidate();
|
this.$refs["from"].clearValidate();
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -100,7 +100,7 @@
|
||||||
{validator: validateURL, trigger: 'blur'}
|
{validator: validateURL, trigger: 'blur'}
|
||||||
],
|
],
|
||||||
path: [
|
path: [
|
||||||
{max: 500, required: true, message: this.$t('commons.input_limit', [1, 500]), trigger: 'blur'},
|
{max: 500, message: this.$t('commons.input_limit', [0, 500]), trigger: 'blur'},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
headerSuggestions: REQUEST_HEADERS
|
headerSuggestions: REQUEST_HEADERS
|
||||||
|
@ -117,13 +117,12 @@
|
||||||
},
|
},
|
||||||
pathChange() {
|
pathChange() {
|
||||||
if (!this.request.path) return;
|
if (!this.request.path) return;
|
||||||
if (!this.request.path.startsWith('/')) {
|
|
||||||
this.request.path = '/' + this.request.path;
|
|
||||||
}
|
|
||||||
let url = this.getURL(this.displayUrl);
|
let url = this.getURL(this.displayUrl);
|
||||||
this
|
let urlStr = url.origin + url.pathname;
|
||||||
.request.path = decodeURIComponent(url.pathname);
|
let envUrl = this.request.environment.protocol + '://' + this.request.environment.socket;
|
||||||
this.request.urlWirhEnv = decodeURIComponent(url.origin + url.pathname);
|
let test = urlStr.substring(envUrl.length, urlStr.length);
|
||||||
|
|
||||||
|
this.request.path = decodeURIComponent(test);
|
||||||
},
|
},
|
||||||
getURL(urlStr) {
|
getURL(urlStr) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -285,11 +285,6 @@ export class HttpRequest extends Request {
|
||||||
isValid: false,
|
isValid: false,
|
||||||
info: 'api_test.request.please_configure_environment_in_scenario'
|
info: 'api_test.request.please_configure_environment_in_scenario'
|
||||||
}
|
}
|
||||||
} else if (!this.path) {
|
|
||||||
return {
|
|
||||||
isValid: false,
|
|
||||||
info: 'api_test.request.input_path'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!this.url) {
|
if (!this.url) {
|
||||||
|
@ -668,12 +663,11 @@ class JMXHttpRequest {
|
||||||
this.protocol = url.protocol.split(":")[0];
|
this.protocol = url.protocol.split(":")[0];
|
||||||
this.pathname = this.getPostQueryParameters(request, decodeURIComponent(url.pathname));
|
this.pathname = this.getPostQueryParameters(request, decodeURIComponent(url.pathname));
|
||||||
} else {
|
} else {
|
||||||
if (environment) {
|
|
||||||
this.port = environment.port;
|
this.port = environment.port;
|
||||||
this.protocol = environment.protocol;
|
this.protocol = environment.protocol;
|
||||||
this.domain = environment.domain;
|
this.domain = environment.domain;
|
||||||
}
|
let url = new URL(environment.protocol + "://" + environment.socket);
|
||||||
this.path = this.getPostQueryParameters(request, decodeURIComponent(request.path));
|
this.path = this.getPostQueryParameters(request, decodeURIComponent(url.pathname));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<el-aside :width="width" class="ms-aside-container"
|
<el-aside :width="width" class="ms-aside-container"
|
||||||
:style="{'margin-left': asideHidden ? '0' : '-' + width}">
|
:style="{'margin-left': asideHidden ? '0' : '-' + width}">
|
||||||
<div class="hiddenBottom" @click="asideHidden = !asideHidden" :style="{'left': width}">
|
<div v-if="enableAsideHidden" class="hiddenBottom" @click="asideHidden = !asideHidden" :style="{'left': width}">
|
||||||
<i v-if="asideHidden" class="el-icon-arrow-left"/>
|
<i v-if="asideHidden" class="el-icon-arrow-left"/>
|
||||||
<i v-if="!asideHidden" class="el-icon-arrow-right"/>
|
<i v-if="!asideHidden" class="el-icon-arrow-right"/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -16,7 +16,11 @@
|
||||||
width: {
|
width: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '300px'
|
default: '300px'
|
||||||
}
|
},
|
||||||
|
enableAsideHidden: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<ms-aside-container :width="width + 'px'">
|
<ms-aside-container :enable-aside-hidden="false" :width="width + 'px'">
|
||||||
<div class="title-bar" :style="{'height': titleBarHeight + 'px'}">
|
<div class="title-bar" :style="{'height': titleBarHeight + 'px'}">
|
||||||
<slot name="title">
|
<slot name="title">
|
||||||
<span :style="{'line-height': titleBarHeight - 10 + 'px'}" class="title-left">
|
<span :style="{'line-height': titleBarHeight - 10 + 'px'}" class="title-left">
|
||||||
|
@ -58,6 +58,10 @@
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
enableAsideHidden: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
itemSelected(index, item) {
|
itemSelected(index, item) {
|
||||||
|
|
Loading…
Reference in New Issue