mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-10 17:30:29 +08:00
路径规则、重写规则、URL跳转规则均支持匹配条件;URL跳转规则增加排序、是否启用功能
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
|||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -48,6 +49,7 @@ func (this *CreateAction) RunPost(params struct {
|
|||||||
IsBreak bool
|
IsBreak bool
|
||||||
IsCaseInsensitive bool
|
IsCaseInsensitive bool
|
||||||
IsReverse bool
|
IsReverse bool
|
||||||
|
CondsJSON []byte
|
||||||
|
|
||||||
Must *actions.Must
|
Must *actions.Must
|
||||||
}) {
|
}) {
|
||||||
@@ -63,6 +65,20 @@ func (this *CreateAction) RunPost(params struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 校验匹配条件
|
||||||
|
if len(params.CondsJSON) > 0 {
|
||||||
|
conds := &shared.HTTPRequestCondsConfig{}
|
||||||
|
err := json.Unmarshal(params.CondsJSON, conds)
|
||||||
|
if err != nil {
|
||||||
|
this.Fail("匹配条件校验失败:" + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
err = conds.Init()
|
||||||
|
if err != nil {
|
||||||
|
this.Fail("匹配条件校验失败:" + err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 自动加上前缀斜杠
|
// 自动加上前缀斜杠
|
||||||
if params.PatternType == serverconfigs.HTTPLocationPatternTypePrefix ||
|
if params.PatternType == serverconfigs.HTTPLocationPatternTypePrefix ||
|
||||||
params.PatternType == serverconfigs.HTTPLocationPatternTypeExact {
|
params.PatternType == serverconfigs.HTTPLocationPatternTypeExact {
|
||||||
@@ -79,6 +95,7 @@ func (this *CreateAction) RunPost(params struct {
|
|||||||
Description: params.Description,
|
Description: params.Description,
|
||||||
Pattern: resultPattern,
|
Pattern: resultPattern,
|
||||||
IsBreak: params.IsBreak,
|
IsBreak: params.IsBreak,
|
||||||
|
CondsJSON: params.CondsJSON,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package location
|
package location
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -28,6 +30,7 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
this.Data["type"] = locationConfig.PatternType()
|
this.Data["type"] = locationConfig.PatternType()
|
||||||
this.Data["isReverse"] = locationConfig.IsReverse()
|
this.Data["isReverse"] = locationConfig.IsReverse()
|
||||||
this.Data["isCaseInsensitive"] = locationConfig.IsCaseInsensitive()
|
this.Data["isCaseInsensitive"] = locationConfig.IsCaseInsensitive()
|
||||||
|
this.Data["conds"] = locationConfig.Conds
|
||||||
|
|
||||||
this.Show()
|
this.Show()
|
||||||
}
|
}
|
||||||
@@ -45,6 +48,8 @@ func (this *IndexAction) RunPost(params struct {
|
|||||||
IsReverse bool
|
IsReverse bool
|
||||||
IsOn bool
|
IsOn bool
|
||||||
|
|
||||||
|
CondsJSON []byte
|
||||||
|
|
||||||
Must *actions.Must
|
Must *actions.Must
|
||||||
}) {
|
}) {
|
||||||
defer this.CreateLogInfo("修改路径规则 %d 设置", params.LocationId)
|
defer this.CreateLogInfo("修改路径规则 %d 设置", params.LocationId)
|
||||||
@@ -67,6 +72,20 @@ func (this *IndexAction) RunPost(params struct {
|
|||||||
params.Pattern = "/" + strings.TrimLeft(params.Pattern, "/")
|
params.Pattern = "/" + strings.TrimLeft(params.Pattern, "/")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 校验匹配条件
|
||||||
|
if len(params.CondsJSON) > 0 {
|
||||||
|
conds := &shared.HTTPRequestCondsConfig{}
|
||||||
|
err := json.Unmarshal(params.CondsJSON, conds)
|
||||||
|
if err != nil {
|
||||||
|
this.Fail("匹配条件校验失败:" + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
err = conds.Init()
|
||||||
|
if err != nil {
|
||||||
|
this.Fail("匹配条件校验失败:" + err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
location := &serverconfigs.HTTPLocationConfig{}
|
location := &serverconfigs.HTTPLocationConfig{}
|
||||||
location.SetPattern(params.Pattern, params.PatternType, params.IsCaseInsensitive, params.IsReverse)
|
location.SetPattern(params.Pattern, params.PatternType, params.IsCaseInsensitive, params.IsReverse)
|
||||||
resultPattern := location.Pattern
|
resultPattern := location.Pattern
|
||||||
@@ -78,6 +97,7 @@ func (this *IndexAction) RunPost(params struct {
|
|||||||
Pattern: resultPattern,
|
Pattern: resultPattern,
|
||||||
IsBreak: params.IsBreak,
|
IsBreak: params.IsBreak,
|
||||||
IsOn: params.IsOn,
|
IsOn: params.IsOn,
|
||||||
|
CondsJSON: params.CondsJSON,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package redirects
|
package redirects
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
"net/url"
|
"net/url"
|
||||||
@@ -30,8 +32,9 @@ func (this *CreatePopupAction) RunPost(params struct {
|
|||||||
MatchPrefix bool
|
MatchPrefix bool
|
||||||
MatchRegexp bool
|
MatchRegexp bool
|
||||||
KeepRequestURI bool
|
KeepRequestURI bool
|
||||||
|
|
||||||
Status int
|
Status int
|
||||||
|
CondsJSON []byte
|
||||||
|
IsOn bool
|
||||||
|
|
||||||
Must *actions.Must
|
Must *actions.Must
|
||||||
CSRF *actionutils.CSRF
|
CSRF *actionutils.CSRF
|
||||||
@@ -80,6 +83,21 @@ func (this *CreatePopupAction) RunPost(params struct {
|
|||||||
Field("status", params.Status).
|
Field("status", params.Status).
|
||||||
Gte(0, "请选择正确的跳转状态码")
|
Gte(0, "请选择正确的跳转状态码")
|
||||||
|
|
||||||
|
// 校验匹配条件
|
||||||
|
var conds *shared.HTTPRequestCondsConfig
|
||||||
|
if len(params.CondsJSON) > 0 {
|
||||||
|
conds = &shared.HTTPRequestCondsConfig{}
|
||||||
|
err := json.Unmarshal(params.CondsJSON, conds)
|
||||||
|
if err != nil {
|
||||||
|
this.Fail("匹配条件校验失败:" + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
err = conds.Init()
|
||||||
|
if err != nil {
|
||||||
|
this.Fail("匹配条件校验失败:" + err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.Data["redirect"] = maps.Map{
|
this.Data["redirect"] = maps.Map{
|
||||||
"status": params.Status,
|
"status": params.Status,
|
||||||
"beforeURL": params.BeforeURL,
|
"beforeURL": params.BeforeURL,
|
||||||
@@ -87,7 +105,8 @@ func (this *CreatePopupAction) RunPost(params struct {
|
|||||||
"matchPrefix": params.MatchPrefix,
|
"matchPrefix": params.MatchPrefix,
|
||||||
"matchRegexp": params.MatchRegexp,
|
"matchRegexp": params.MatchRegexp,
|
||||||
"keepRequestURI": params.KeepRequestURI,
|
"keepRequestURI": params.KeepRequestURI,
|
||||||
"isOn": true,
|
"conds": conds,
|
||||||
|
"isOn": params.IsOn,
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Success()
|
this.Success()
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
"github.com/iwind/TeaGo/types"
|
"github.com/iwind/TeaGo/types"
|
||||||
"regexp"
|
"regexp"
|
||||||
@@ -37,6 +38,8 @@ func (this *CreatePopupAction) RunPost(params struct {
|
|||||||
IsBreak bool
|
IsBreak bool
|
||||||
IsOn bool
|
IsOn bool
|
||||||
|
|
||||||
|
CondsJSON []byte
|
||||||
|
|
||||||
Must *actions.Must
|
Must *actions.Must
|
||||||
}) {
|
}) {
|
||||||
params.Must.
|
params.Must.
|
||||||
@@ -54,6 +57,20 @@ func (this *CreatePopupAction) RunPost(params struct {
|
|||||||
Field("replace", params.Replace).
|
Field("replace", params.Replace).
|
||||||
Require("请输入目标URL")
|
Require("请输入目标URL")
|
||||||
|
|
||||||
|
// 校验匹配条件
|
||||||
|
if len(params.CondsJSON) > 0 {
|
||||||
|
conds := &shared.HTTPRequestCondsConfig{}
|
||||||
|
err := json.Unmarshal(params.CondsJSON, conds)
|
||||||
|
if err != nil {
|
||||||
|
this.Fail("匹配条件校验失败:" + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
err = conds.Init()
|
||||||
|
if err != nil {
|
||||||
|
this.Fail("匹配条件校验失败:" + err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// web配置
|
// web配置
|
||||||
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithId(this.AdminContext(), params.WebId)
|
webConfig, err := dao.SharedHTTPWebDAO.FindWebConfigWithId(this.AdminContext(), params.WebId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -71,6 +88,7 @@ func (this *CreatePopupAction) RunPost(params struct {
|
|||||||
WithQuery: params.WithQuery,
|
WithQuery: params.WithQuery,
|
||||||
IsBreak: params.IsBreak,
|
IsBreak: params.IsBreak,
|
||||||
IsOn: params.IsOn,
|
IsOn: params.IsOn,
|
||||||
|
CondsJSON: params.CondsJSON,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package rewrite
|
package rewrite
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
"github.com/iwind/TeaGo/types"
|
"github.com/iwind/TeaGo/types"
|
||||||
"regexp"
|
"regexp"
|
||||||
@@ -56,6 +58,7 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
|||||||
WithQuery bool
|
WithQuery bool
|
||||||
IsBreak bool
|
IsBreak bool
|
||||||
IsOn bool
|
IsOn bool
|
||||||
|
CondsJSON []byte
|
||||||
|
|
||||||
Must *actions.Must
|
Must *actions.Must
|
||||||
}) {
|
}) {
|
||||||
@@ -76,6 +79,20 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
|||||||
Field("replace", params.Replace).
|
Field("replace", params.Replace).
|
||||||
Require("请输入目标URL")
|
Require("请输入目标URL")
|
||||||
|
|
||||||
|
// 校验匹配条件
|
||||||
|
if len(params.CondsJSON) > 0 {
|
||||||
|
conds := &shared.HTTPRequestCondsConfig{}
|
||||||
|
err := json.Unmarshal(params.CondsJSON, conds)
|
||||||
|
if err != nil {
|
||||||
|
this.Fail("匹配条件校验失败:" + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
err = conds.Init()
|
||||||
|
if err != nil {
|
||||||
|
this.Fail("匹配条件校验失败:" + err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 修改
|
// 修改
|
||||||
_, err := this.RPC().HTTPRewriteRuleRPC().UpdateHTTPRewriteRule(this.AdminContext(), &pb.UpdateHTTPRewriteRuleRequest{
|
_, err := this.RPC().HTTPRewriteRuleRPC().UpdateHTTPRewriteRule(this.AdminContext(), &pb.UpdateHTTPRewriteRuleRequest{
|
||||||
RewriteRuleId: params.RewriteRuleId,
|
RewriteRuleId: params.RewriteRuleId,
|
||||||
@@ -87,6 +104,7 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
|||||||
WithQuery: params.WithQuery,
|
WithQuery: params.WithQuery,
|
||||||
IsBreak: params.IsBreak,
|
IsBreak: params.IsBreak,
|
||||||
IsOn: params.IsOn,
|
IsOn: params.IsOn,
|
||||||
|
CondsJSON: params.CondsJSON,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
|
|||||||
@@ -1,11 +1,31 @@
|
|||||||
Vue.component("http-host-redirect-box", {
|
Vue.component("http-host-redirect-box", {
|
||||||
props: ["v-redirects"],
|
props: ["v-redirects"],
|
||||||
|
mounted: function () {
|
||||||
|
let that = this
|
||||||
|
sortTable(function (ids) {
|
||||||
|
let newRedirects = []
|
||||||
|
ids.forEach(function (id) {
|
||||||
|
that.redirects.forEach(function (redirect) {
|
||||||
|
if (redirect.id == id) {
|
||||||
|
newRedirects.push(redirect)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
that.updateRedirects(newRedirects)
|
||||||
|
})
|
||||||
|
},
|
||||||
data: function () {
|
data: function () {
|
||||||
let redirects = this.vRedirects
|
let redirects = this.vRedirects
|
||||||
if (redirects == null) {
|
if (redirects == null) {
|
||||||
redirects = []
|
redirects = []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let id = 0
|
||||||
|
redirects.forEach(function (v) {
|
||||||
|
id++
|
||||||
|
v.id = id
|
||||||
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
redirects: redirects,
|
redirects: redirects,
|
||||||
statusOptions: [
|
statusOptions: [
|
||||||
@@ -14,7 +34,8 @@ Vue.component("http-host-redirect-box", {
|
|||||||
{"code": 302, "text": "Found"},
|
{"code": 302, "text": "Found"},
|
||||||
{"code": 303, "text": "See Other"},
|
{"code": 303, "text": "See Other"},
|
||||||
{"code": 307, "text": "Temporary Redirect"}
|
{"code": 307, "text": "Temporary Redirect"}
|
||||||
]
|
],
|
||||||
|
id: id
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -23,9 +44,13 @@ Vue.component("http-host-redirect-box", {
|
|||||||
window.UPDATING_REDIRECT = null
|
window.UPDATING_REDIRECT = null
|
||||||
|
|
||||||
teaweb.popup("/servers/server/settings/redirects/createPopup", {
|
teaweb.popup("/servers/server/settings/redirects/createPopup", {
|
||||||
height: "22em",
|
width: "50em",
|
||||||
|
height: "30em",
|
||||||
callback: function (resp) {
|
callback: function (resp) {
|
||||||
|
that.id++
|
||||||
|
resp.data.redirect.id = that.id
|
||||||
that.redirects.push(resp.data.redirect)
|
that.redirects.push(resp.data.redirect)
|
||||||
|
that.change()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -34,31 +59,84 @@ Vue.component("http-host-redirect-box", {
|
|||||||
window.UPDATING_REDIRECT = redirect
|
window.UPDATING_REDIRECT = redirect
|
||||||
|
|
||||||
teaweb.popup("/servers/server/settings/redirects/createPopup", {
|
teaweb.popup("/servers/server/settings/redirects/createPopup", {
|
||||||
height: "22em",
|
width: "50em",
|
||||||
|
height: "30em",
|
||||||
callback: function (resp) {
|
callback: function (resp) {
|
||||||
|
resp.data.redirect.id = redirect.id
|
||||||
Vue.set(that.redirects, index, resp.data.redirect)
|
Vue.set(that.redirects, index, resp.data.redirect)
|
||||||
|
that.change()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
remove: function (index) {
|
remove: function (index) {
|
||||||
this.redirects.$remove(index)
|
this.redirects.$remove(index)
|
||||||
|
this.change()
|
||||||
|
},
|
||||||
|
change: function () {
|
||||||
|
let that = this
|
||||||
|
setTimeout(function (){
|
||||||
|
that.$emit("change", that.redirects)
|
||||||
|
}, 100)
|
||||||
|
},
|
||||||
|
updateRedirects: function (newRedirects) {
|
||||||
|
this.redirects = newRedirects
|
||||||
|
this.change()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
template: `<div>
|
template: `<div>
|
||||||
<input type="hidden" name="hostRedirectsJSON" :value="JSON.stringify(redirects)"/>
|
<input type="hidden" name="hostRedirectsJSON" :value="JSON.stringify(redirects)"/>
|
||||||
|
|
||||||
|
<first-menu>
|
||||||
|
<menu-item @click.prevent="add">[创建]</menu-item>
|
||||||
|
</first-menu>
|
||||||
|
<div class="margin"></div>
|
||||||
|
|
||||||
<!-- TODO 将来支持排序,并支持isOn切换 -->
|
<!-- TODO 将来支持排序,并支持isOn切换 -->
|
||||||
<div v-if="redirects.length > 0">
|
<p class="comment" v-if="redirects.length == 0">暂时还没有URL跳转规则。</p>
|
||||||
<div v-for="(redirect, index) in redirects" class="ui label basic small" style="margin-bottom: 0.5em;margin-top: 0.5em">
|
<div v-show="redirects.length > 0">
|
||||||
<span v-if="redirect.status > 0" class="small grey">[{{redirect.status}}]</span>
|
<table class="ui table celled selectable" id="sortable-table">
|
||||||
<span v-if="redirect.matchPrefix" class="small grey">[匹配前缀]</span>
|
<thead>
|
||||||
<span v-if="redirect.matchRegexp" class="small grey">[正则匹配]</span>
|
<tr>
|
||||||
{{redirect.beforeURL}} -> {{redirect.afterURL}} <a href="" @click.prevent="update(index, redirect)" title="修改"><i class="icon pencil small"></i></a> <a href="" @click.prevent="remove(index)" title="删除"><i class="icon remove"></i></a>
|
<th style="width: 1em"></th>
|
||||||
|
<th>跳转前URL</th>
|
||||||
|
<th style="width: 1em"></th>
|
||||||
|
<th>跳转后URL</th>
|
||||||
|
<th>匹配模式</th>
|
||||||
|
<th>HTTP状态码</th>
|
||||||
|
<th class="two wide">状态</th>
|
||||||
|
<th class="two op">操作</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody v-for="(redirect, index) in redirects" :key="redirect.id" :v-id="redirect.id">
|
||||||
|
<tr>
|
||||||
|
<td style="text-align: center;"><i class="icon bars handle grey"></i> </td>
|
||||||
|
<td>
|
||||||
|
{{redirect.beforeURL}}
|
||||||
|
<div style="margin-top: 0.5em" v-if="redirect.conds != null && redirect.conds.groups != null && redirect.conds.groups.length > 0">
|
||||||
|
<span class="ui label text basic tiny">匹配条件</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui divider"></div>
|
</td>
|
||||||
</div>
|
<td nowrap="">-></td>
|
||||||
<div>
|
<td>{{redirect.afterURL}}</td>
|
||||||
<button type="button" class="ui button tiny" @click.prevent="add">+</button>
|
<td>
|
||||||
|
<span v-if="redirect.matchPrefix">匹配前缀</span>
|
||||||
|
<span v-if="redirect.matchRegexp">正则匹配</span>
|
||||||
|
<span v-if="!redirect.matchPrefix && !redirect.matchRegexp">精准匹配</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<span v-if="redirect.status > 0">{{redirect.status}}</span>
|
||||||
|
<span v-else class="disabled">默认</span>
|
||||||
|
</td>
|
||||||
|
<td><label-on :v-is-on="redirect.isOn"></label-on></td>
|
||||||
|
<td>
|
||||||
|
<a href="" @click.prevent="update(index, redirect)">修改</a>
|
||||||
|
<a href="" @click.prevent="remove(index)">删除</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<p class="comment" v-if="redirects.length > 1">所有规则匹配顺序为从上到下,可以拖动左侧的<i class="icon bars"></i>排序。</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="margin"></div>
|
||||||
</div>`
|
</div>`
|
||||||
})
|
})
|
||||||
@@ -40,6 +40,12 @@
|
|||||||
<p class="comment">可以用来说明此规则用途。。</p>
|
<p class="comment">可以用来说明此规则用途。。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>匹配条件</td>
|
||||||
|
<td>
|
||||||
|
<http-request-conds-box></http-request-conds-box>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2"><more-options-indicator></more-options-indicator></td>
|
<td colspan="2"><more-options-indicator></more-options-indicator></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -42,6 +42,12 @@
|
|||||||
<p class="comment">可以用来说明此规则用途。。</p>
|
<p class="comment">可以用来说明此规则用途。。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>匹配条件</td>
|
||||||
|
<td>
|
||||||
|
<http-request-conds-box :v-conds="conds"></http-request-conds-box>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2"><more-options-indicator></more-options-indicator></td>
|
<td colspan="2"><more-options-indicator></more-options-indicator></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ Tea.context(function () {
|
|||||||
teaweb.popup("/servers/server/settings/rewrite/createPopup?webId=" + this.webId, {
|
teaweb.popup("/servers/server/settings/rewrite/createPopup?webId=" + this.webId, {
|
||||||
height: "26em",
|
height: "26em",
|
||||||
callback: function () {
|
callback: function () {
|
||||||
window.location.reload()
|
teaweb.success("保存成功", function () {
|
||||||
|
teaweb.reload()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,14 @@
|
|||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</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>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<submit-btn></submit-btn>
|
<submit-btn></submit-btn>
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ Tea.context(function () {
|
|||||||
afterURL: "",
|
afterURL: "",
|
||||||
matchPrefix: false,
|
matchPrefix: false,
|
||||||
matchRegexp: false,
|
matchRegexp: false,
|
||||||
keepRequestURI: false
|
keepRequestURI: false,
|
||||||
|
conds: null,
|
||||||
|
isOn: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,4 +40,8 @@ Tea.context(function () {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.changeConds = function (conds) {
|
||||||
|
this.redirect.conds = conds
|
||||||
|
}
|
||||||
})
|
})
|
||||||
@@ -4,14 +4,7 @@
|
|||||||
<div class="right-box">
|
<div class="right-box">
|
||||||
<form class="ui form" method="post" data-tea-action="$" data-tea-success="success">
|
<form class="ui form" method="post" data-tea-action="$" data-tea-success="success">
|
||||||
<input type="hidden" name="webId" :value="webId"/>
|
<input type="hidden" name="webId" :value="webId"/>
|
||||||
<table class="ui table selectable definition">
|
<http-host-redirect-box :v-redirects="redirects" @change="change"></http-host-redirect-box>
|
||||||
<tr>
|
|
||||||
<td class="title">URL跳转设置</td>
|
|
||||||
<td>
|
|
||||||
<http-host-redirect-box :v-redirects="redirects"></http-host-redirect-box>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<submit-btn></submit-btn>
|
<submit-btn></submit-btn>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,3 +1,14 @@
|
|||||||
Tea.context(function () {
|
Tea.context(function () {
|
||||||
this.success = NotifyReloadSuccess("保存成功")
|
this.success = NotifyReloadSuccess("保存成功")
|
||||||
|
|
||||||
|
this.change = function (values) {
|
||||||
|
this.$post("$")
|
||||||
|
.params({
|
||||||
|
webId: this.webId,
|
||||||
|
hostRedirectsJSON: JSON.stringify(values)
|
||||||
|
})
|
||||||
|
.success(function () {
|
||||||
|
NotifyReloadSuccess("保存成功")()
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
@@ -28,6 +28,10 @@
|
|||||||
<p class="comment">隐式表示不在客户端显示重写后的URL;显式表示在客户端跳转URL,将会显示重写后的URL。</p>
|
<p class="comment">隐式表示不在客户端显示重写后的URL;显式表示在客户端跳转URL,将会显示重写后的URL。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>匹配条件</td>
|
||||||
|
<td><http-request-conds-box></http-request-conds-box></td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2"><more-options-indicator></more-options-indicator></td>
|
<td colspan="2"><more-options-indicator></more-options-indicator></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ Tea.context(function () {
|
|||||||
teaweb.popup("/servers/server/settings/rewrite/createPopup?webId=" + this.webId, {
|
teaweb.popup("/servers/server/settings/rewrite/createPopup?webId=" + this.webId, {
|
||||||
height: "26em",
|
height: "26em",
|
||||||
callback: function () {
|
callback: function () {
|
||||||
window.location.reload()
|
teaweb.success("保存成功", function () {
|
||||||
|
teaweb.reload()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,10 @@
|
|||||||
<p class="comment">隐式表示不在客户端显示重写后的URL;显式表示在客户端跳转URL,将会显示重写后的URL。</p>
|
<p class="comment">隐式表示不在客户端显示重写后的URL;显式表示在客户端跳转URL,将会显示重写后的URL。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>匹配条件</td>
|
||||||
|
<td><http-request-conds-box :v-conds="rewriteRule.conds"></http-request-conds-box></td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2"><more-options-indicator></more-options-indicator></td>
|
<td colspan="2"><more-options-indicator></more-options-indicator></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
Reference in New Issue
Block a user