创建网站服务时强制填写域名/优化源站未填写时交互

This commit is contained in:
刘祥超
2022-05-07 20:26:40 +08:00
parent 34b7cfec6f
commit 36326697d7
4 changed files with 44 additions and 15 deletions

View File

@@ -3,7 +3,7 @@
<div class="margin"></div>
<form method="post" class="ui form" data-tea-action="$" data-tea-success="success">
<form method="post" class="ui form" data-tea-action="$" data-tea-success="success" data-tea-fail="fail">
<table class="ui table selectable definition">
<tr>
<td class="title">服务名称 *</td>
@@ -45,7 +45,7 @@
<tr v-if="serverType == 'httpProxy' || serverType == 'httpWeb'">
<td>绑定域名 *</td>
<td>
<server-name-box></server-name-box>
<server-name-box ref="serverNameBox"></server-name-box>
<p class="comment">绑定后,才能通过域名可以访问不同的服务。</p>
</td>
</tr>

View File

@@ -6,6 +6,32 @@ Tea.context(function () {
this.success = NotifySuccess("保存成功", "/servers");
this.fail = function (resp) {
if (resp.errors != null && resp.errors.length > 0) {
let isFiltered = false
let that = this
resp.errors.forEach(function (err) {
if (err.param == "emptyDomain") {
isFiltered = true
teaweb.warn(err.messages[0], function () {
that.$refs.serverNameBox.addServerName()
})
} else if (err.param == "emptyOrigin") {
isFiltered = true
teaweb.warn(err.messages[0], function () {
that.addOrigin()
})
}
})
if (isFiltered) {
return
}
}
Tea.failResponse(resp)
}
this.changeServerType = function () {
this.origins = []
this.tlsProtocolName = ""