refactor(环境管理): 域名长度限制调整到 253

Signed-off-by: fit2-zhao <yong.zhao@fit2cloud.com>
This commit is contained in:
fit2-zhao 2024-11-04 14:52:08 +08:00 committed by Craftsman
parent 576aba0a06
commit 475498e636
1 changed files with 138 additions and 124 deletions

View File

@ -25,27 +25,41 @@
<el-table-column :label="$t('commons.operating')" width="100"> <el-table-column :label="$t('commons.operating')" width="100">
<template v-slot:default="scope"> <template v-slot:default="scope">
<span> <span>
<el-button size="mini" p="$t('commons.remove')" icon="el-icon-close" circle @click="remove(scope.row)" <el-button
size="mini"
p="$t('commons.remove')"
icon="el-icon-close"
circle
@click="remove(scope.row)"
class="ht-btn-remove" /> class="ht-btn-remove" />
<el-button size="mini" p="$t('commons.save')" icon="el-icon-check" type="primary" circle @click="confirm(scope.row)" <el-button
size="mini"
p="$t('commons.save')"
icon="el-icon-check"
type="primary"
circle
@click="confirm(scope.row)"
class="ht-btn-confirm" /> class="ht-btn-confirm" />
</span> </span>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<el-button class="ht-btn-add" size="mini" p="$t('commons.add')" icon="el-icon-circle-plus-outline" @click="add">{{$t("commons.add")}}</el-button> <el-button class="ht-btn-add" size="mini" p="$t('commons.add')" icon="el-icon-circle-plus-outline" @click="add">{{
<el-button class="ht-btn-add" size="mini" p="$t('commons.add')" icon="el-icon-files" @click="copy">{{$t("commons.copy")}}</el-button> $t('commons.add')
}}</el-button>
<el-button class="ht-btn-add" size="mini" p="$t('commons.add')" icon="el-icon-files" @click="copy">{{
$t('commons.copy')
}}</el-button>
</div> </div>
</template> </template>
<script> <script>
import MsApiVariableInput from "./ApiVariableInput"; import MsApiVariableInput from './ApiVariableInput';
import MsTableOperatorButton from "../../MsTableOperatorButton"; import MsTableOperatorButton from '../../MsTableOperatorButton';
export default { export default {
name: "MsApiHostTable", name: 'MsApiHostTable',
components: { MsApiVariableInput, MsTableOperatorButton }, components: { MsApiVariableInput, MsTableOperatorButton },
props: { props: {
hostTable: Array, hostTable: Array,
@ -55,7 +69,7 @@
currentPage: 1, currentPage: 1,
pageSize: 5, pageSize: 5,
total: 0, total: 0,
} };
}, },
created() { created() {
this.init(); this.init();
@ -74,7 +88,7 @@
status: 'edit', status: 'edit',
annotation: '', annotation: '',
uuid: this.uuid(), uuid: this.uuid(),
} };
this.hostTable.push(row); this.hostTable.push(row);
}, },
copy: function (r) { copy: function (r) {
@ -84,7 +98,7 @@
status: 'edit', status: 'edit',
annotation: '', annotation: '',
uuid: this.uuid(), uuid: this.uuid(),
} };
// //
for (let i = this.hostTable.length - 1; i >= 0; i--) { for (let i = this.hostTable.length - 1; i >= 0; i--) {
if (this.hostTable[i].status === '') { if (this.hostTable[i].status === '') {
@ -98,9 +112,9 @@
this.hostTable.push(row); this.hostTable.push(row);
}, },
confirm: function (row) { confirm: function (row) {
this.validateIp(row.ip) && this.validateDomain(row.domain) ? row.status = '' : row.status; this.validateIp(row.ip) && this.validateDomain(row.domain) ? (row.status = '') : row.status;
this.$emit('change', this.hostTable); this.$emit('change', this.hostTable);
if (row.status === "") { if (row.status === '') {
return true; return true;
} }
return false; return false;
@ -112,23 +126,24 @@
domain: '', domain: '',
status: 'edit', status: 'edit',
annotation: '', annotation: '',
uuid: this.uuid() uuid: this.uuid(),
} };
this.hostTable.push(row); this.hostTable.push(row);
} }
}, },
validateIp(ip) { validateIp(ip) {
let regexp = /^((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}$/; let regexp = /^((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}$/;
if (regexp.test(ip) == false) { if (regexp.test(ip) === false) {
this.$warning(this.$t('load_test.input_ip')); this.$warning(this.$t('load_test.input_ip'));
return false; return false;
} }
return true; return true;
}, },
validateDomain(domain) { validateDomain(domain) {
let strRegex = "^(?=^.{3,255}$)(http(s)?:\\/\\/)?(www\\.)?[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+(:\\d+)*(\\/\\w+\\.\\w+)*$"; let strRegex =
'^(?=^.{3,255}$)(http(s)?:\\/\\/)?(www\\.)?[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+(:\\d+)*(\\/\\w+\\.\\w+)*$';
const re = new RegExp(strRegex); const re = new RegExp(strRegex);
if (re.test(domain) && domain.length < 67) { if (re.test(domain) && domain.length < 253) {
return true; return true;
} }
this.$warning(this.$t('load_test.input_domain')); this.$warning(this.$t('load_test.input_domain'));
@ -140,15 +155,14 @@
uuid: function () { uuid: function () {
return (((1 + Math.random()) * 0x100000) | 0).toString(16).substring(1); return (((1 + Math.random()) * 0x100000) | 0).toString(16).substring(1);
}, },
} },
} };
</script> </script>
<style scoped> <style scoped>
.ht-btn-remove { .ht-btn-remove {
color: white; color: white;
background-color: #DCDFE6; background-color: #dcdfe6;
} }
.ht-btn-confirm { .ht-btn-confirm {