URL跳转中增加例外域名和仅限域名

This commit is contained in:
刘祥超
2023-11-10 11:05:05 +08:00
parent 869ebd59d1
commit 51905a0ee3
3 changed files with 55 additions and 9 deletions

View File

@@ -52,7 +52,11 @@ func (this *CreatePopupAction) RunPost(params struct {
PortAfter int
PortAfterScheme string
Status int
Status int
ExceptDomainsJSON []byte
OnlyDomainsJSON []byte
CondsJSON []byte
IsOn bool
@@ -186,6 +190,27 @@ func (this *CreatePopupAction) RunPost(params struct {
Field("status", params.Status).
Gte(0, "请选择正确的跳转状态码")
// 域名
if len(params.ExceptDomainsJSON) > 0 {
var exceptDomains = []string{}
err := json.Unmarshal(params.ExceptDomainsJSON, &exceptDomains)
if err != nil {
this.ErrorPage(err)
return
}
config.ExceptDomains = exceptDomains
}
if len(params.OnlyDomainsJSON) > 0 {
var onlyDomains = []string{}
err := json.Unmarshal(params.OnlyDomainsJSON, &onlyDomains)
if err != nil {
this.ErrorPage(err)
return
}
config.OnlyDomains = onlyDomains
}
// 校验匹配条件
var conds *shared.HTTPRequestCondsConfig
if len(params.CondsJSON) > 0 {

View File

@@ -45,7 +45,7 @@ Vue.component("http-host-redirect-box", {
teaweb.popup("/servers/server/settings/redirects/createPopup", {
width: "50em",
height: "30em",
height: "36em",
callback: function (resp) {
that.id++
resp.data.redirect.id = that.id
@@ -60,7 +60,7 @@ Vue.component("http-host-redirect-box", {
teaweb.popup("/servers/server/settings/redirects/createPopup", {
width: "50em",
height: "30em",
height: "36em",
callback: function (resp) {
resp.data.redirect.id = redirect.id
Vue.set(that.redirects, index, resp.data.redirect)
@@ -119,6 +119,8 @@ Vue.component("http-host-redirect-box", {
<grey-label v-if="redirect.matchPrefix">匹配前缀</grey-label>
<grey-label v-if="redirect.matchRegexp">正则匹配</grey-label>
<grey-label v-if="!redirect.matchPrefix && !redirect.matchRegexp">精准匹配</grey-label>
<grey-label v-if="redirect.exceptDomains != null && redirect.exceptDomains.length > 0" v-for="domain in redirect.exceptDomains">排除:{{domain}}</grey-label>
<grey-label v-if="redirect.onlyDomains != null && redirect.onlyDomains.length > 0" v-for="domain in redirect.onlyDomains">仅限:{{domain}}</grey-label>
</div>
</div>
<div v-if="redirect.type == 'domain'">

View File

@@ -151,13 +151,32 @@
</td>
</tr>
<tr>
<td>匹配条件</td>
<td><http-request-conds-box :v-conds="redirect.conds" @change="changeConds"></http-request-conds-box></td>
</tr>
<tr>
<td>启用当前跳转</td>
<td><checkbox name="isOn" value="1" v-model="redirect.isOn"></checkbox></td>
<td colspan="2"><more-options-indicator></more-options-indicator></td>
</tr>
<tbody v-show="moreOptionsVisible">
<tr>
<td>例外域名</td>
<td>
<domains-box name="exceptDomainsJSON" :v-domains="redirect.exceptDomains"></domains-box>
<p class="comment">这些域名<strong></strong>执行跳转。</p>
</td>
</tr>
<tr>
<td>仅限域名</td>
<td>
<domains-box name="onlyDomainsJSON" :v-domains="redirect.onlyDomains"></domains-box>
<p class="comment">只有这些域名执行跳转。</p>
</td>
</tr>
<tr>
<td>匹配条件</td>
<td><http-request-conds-box :v-conds="redirect.conds" @change="changeConds"></http-request-conds-box></td>
</tr>
<tr>
<td>启用当前跳转</td>
<td><checkbox name="isOn" value="1" v-model="redirect.isOn"></checkbox></td>
</tr>
</tbody>
</table>
<submit-btn></submit-btn>