URL跳转增加匹配前缀和是否保留RequestURI选项

This commit is contained in:
GoEdgeLab
2021-04-07 11:20:23 +08:00
parent 46cb692e5a
commit 7d66cc3cae
4 changed files with 48 additions and 21 deletions

View File

@@ -24,9 +24,12 @@ func (this *CreatePopupAction) RunGet(params struct {
}
func (this *CreatePopupAction) RunPost(params struct {
BeforeURL string
AfterURL string
Status int
BeforeURL string
AfterURL string
MatchPrefix bool
KeepRequestURI bool
Status int
Must *actions.Must
CSRF *actionutils.CSRF
@@ -69,10 +72,12 @@ func (this *CreatePopupAction) RunPost(params struct {
Gte(0, "请选择正确的跳转状态码")
this.Data["redirect"] = maps.Map{
"status": params.Status,
"beforeURL": params.BeforeURL,
"afterURL": params.AfterURL,
"isOn": true,
"status": params.Status,
"beforeURL": params.BeforeURL,
"afterURL": params.AfterURL,
"matchPrefix": params.MatchPrefix,
"keepRequestURI": params.KeepRequestURI,
"isOn": true,
}
this.Success()

View File

@@ -50,7 +50,7 @@ Vue.component("http-host-redirect-box", {
<!-- TODO 将来支持排序并支持isOn切换 -->
<div v-if="redirects.length > 0">
<div v-for="(redirect, index) in redirects" class="ui label basic small" style="margin-bottom: 0.5em;margin-top: 0.5em">
<span v-if="redirect.status > 0">[{{redirect.status}}]</span> {{redirect.beforeURL}} -&gt; {{redirect.afterURL}} <a href="" @click.prevent="update(index, redirect)" title="修改"><i class="icon pencil small"></i></a> &nbsp; <a href="" @click.prevent="remove(index)" title="删除"><i class="icon remove"></i></a>
<span v-if="redirect.status > 0">[{{redirect.status}}]</span><span v-if="redirect.matchPrefix">[prefix]</span> {{redirect.beforeURL}} -&gt; {{redirect.afterURL}} <a href="" @click.prevent="update(index, redirect)" title="修改"><i class="icon pencil small"></i></a> &nbsp; <a href="" @click.prevent="remove(index)" title="删除"><i class="icon remove"></i></a>
</div>
<div class="ui divider"></div>
</div>

View File

@@ -8,12 +8,30 @@
<table class="ui table definition selectable">
<tr>
<td>跳转前URL *</td>
<td class="title">跳转前URL *</td>
<td>
<input type="text" name="beforeURL" placeholder="比如 http://www.url1.com" v-model="redirect.beforeURL" ref="focus"/>
<p class="comment">需要填写完整的URL包括<code-label>http://</code-label>或者<code-label>https://</code-label>,如果有非默认端口,也需要带上端口号。</p>
</td>
</tr>
<tr>
<td>匹配模式</td>
<td>
<select class="ui dropdown auto-width" name="matchPrefix" v-model="matchPrefix">
<option value="0">精准匹配</option>
<option value="1">匹配前缀</option>
</select>
<p class="comment" v-if="matchPrefix == 0">精准匹配跳转前的URL。</p>
<p class="comment" v-if="matchPrefix == 1">只要URL头部部分包含跳转前URL即可跳转。</p>
</td>
</tr>
<tr v-if="matchPrefix == 1">
<td>是否保留URL路径参数</td>
<td>
<checkbox name="keepRequestURI" value="1" v-model="redirect.keepRequestURI"></checkbox>
<p class="comment">选中后则跳转之后保留跳转之前的URL路径和参数。</p>
</td>
</tr>
<tr>
<td>跳转后URL *</td>
<td>
@@ -22,7 +40,7 @@
</td>
</tr>
<tr>
<td class="title">跳转状态码</td>
<td>跳转状态码</td>
<td>
<select class="ui dropdown auto-width" name="status" v-model="redirect.status">
<option value="0">[默认]</option>

View File

@@ -1,13 +1,17 @@
Tea.context(function () {
this.isCreating = true
if (window.parent.UPDATING_REDIRECT != null) {
this.isCreating = false
this.redirect = window.parent.UPDATING_REDIRECT
} else {
this.redirect = {
status: 0,
beforeURL: "",
afterURL: ""
}
}
this.isCreating = true
if (window.parent.UPDATING_REDIRECT != null) {
this.isCreating = false
this.redirect = window.parent.UPDATING_REDIRECT
} else {
this.redirect = {
status: 0,
beforeURL: "",
afterURL: "",
matchPrefix: false,
keepRequestURI: false
}
}
this.matchPrefix = (this.redirect.matchPrefix ? 1 : 0)
})