mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-06 23:00:25 +08:00
路由规则增加专属域名设置
This commit is contained in:
@@ -51,8 +51,12 @@ func (this *CreateAction) RunPost(params struct {
|
|||||||
IsReverse bool
|
IsReverse bool
|
||||||
CondsJSON []byte
|
CondsJSON []byte
|
||||||
|
|
||||||
|
DomainsJSON []byte
|
||||||
|
|
||||||
Must *actions.Must
|
Must *actions.Must
|
||||||
}) {
|
}) {
|
||||||
|
defer this.CreateLogInfo("创建路由规则:%s", params.Pattern)
|
||||||
|
|
||||||
params.Must.
|
params.Must.
|
||||||
Field("pattern", params.Pattern).
|
Field("pattern", params.Pattern).
|
||||||
Require("请输入路径匹配规则")
|
Require("请输入路径匹配规则")
|
||||||
@@ -85,6 +89,21 @@ func (this *CreateAction) RunPost(params struct {
|
|||||||
params.Pattern = "/" + strings.TrimLeft(params.Pattern, "/")
|
params.Pattern = "/" + strings.TrimLeft(params.Pattern, "/")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 域名
|
||||||
|
var domains = []string{}
|
||||||
|
if len(params.DomainsJSON) > 0 {
|
||||||
|
err := json.Unmarshal(params.DomainsJSON, &domains)
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 去除可能误加的斜杠
|
||||||
|
for index, domain := range domains {
|
||||||
|
domains[index] = strings.TrimSuffix(domain, "/")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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
|
||||||
@@ -96,6 +115,7 @@ func (this *CreateAction) RunPost(params struct {
|
|||||||
Pattern: resultPattern,
|
Pattern: resultPattern,
|
||||||
IsBreak: params.IsBreak,
|
IsBreak: params.IsBreak,
|
||||||
CondsJSON: params.CondsJSON,
|
CondsJSON: params.CondsJSON,
|
||||||
|
Domains: domains,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
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.Data["conds"] = locationConfig.Conds
|
||||||
|
this.Data["domains"] = locationConfig.Domains
|
||||||
|
|
||||||
this.Show()
|
this.Show()
|
||||||
}
|
}
|
||||||
@@ -50,6 +51,8 @@ func (this *IndexAction) RunPost(params struct {
|
|||||||
|
|
||||||
CondsJSON []byte
|
CondsJSON []byte
|
||||||
|
|
||||||
|
DomainsJSON []byte
|
||||||
|
|
||||||
Must *actions.Must
|
Must *actions.Must
|
||||||
}) {
|
}) {
|
||||||
defer this.CreateLogInfo("修改路由规则 %d 设置", params.LocationId)
|
defer this.CreateLogInfo("修改路由规则 %d 设置", params.LocationId)
|
||||||
@@ -86,6 +89,21 @@ func (this *IndexAction) RunPost(params struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 域名
|
||||||
|
var domains = []string{}
|
||||||
|
if len(params.DomainsJSON) > 0 {
|
||||||
|
err := json.Unmarshal(params.DomainsJSON, &domains)
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 去除可能误加的斜杠
|
||||||
|
for index, domain := range domains {
|
||||||
|
domains[index] = strings.TrimSuffix(domain, "/")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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
|
||||||
@@ -98,6 +116,7 @@ func (this *IndexAction) RunPost(params struct {
|
|||||||
IsBreak: params.IsBreak,
|
IsBreak: params.IsBreak,
|
||||||
IsOn: params.IsOn,
|
IsOn: params.IsOn,
|
||||||
CondsJSON: params.CondsJSON,
|
CondsJSON: params.CondsJSON,
|
||||||
|
Domains: domains,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
|
|||||||
@@ -25,6 +25,13 @@ Vue.component("http-location-labels", {
|
|||||||
template: ` <div class="labels-box">
|
template: ` <div class="labels-box">
|
||||||
<!-- 基本信息 -->
|
<!-- 基本信息 -->
|
||||||
<http-location-labels-label v-if="location.name != null && location.name.length > 0" :class="'olive'" :href="url('/location')">{{location.name}}</http-location-labels-label>
|
<http-location-labels-label v-if="location.name != null && location.name.length > 0" :class="'olive'" :href="url('/location')">{{location.name}}</http-location-labels-label>
|
||||||
|
|
||||||
|
<!-- domains -->
|
||||||
|
<div v-if="location.domains != null && location.domains.length > 0">
|
||||||
|
<grey-label v-for="domain in location.domains">{{domain}}</grey-label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- break -->
|
||||||
<http-location-labels-label v-if="location.isBreak" :href="url('/location')">BREAK</http-location-labels-label>
|
<http-location-labels-label v-if="location.isBreak" :href="url('/location')">BREAK</http-location-labels-label>
|
||||||
|
|
||||||
<!-- redirectToHTTPS -->
|
<!-- redirectToHTTPS -->
|
||||||
|
|||||||
@@ -51,6 +51,13 @@
|
|||||||
<td colspan="2"><more-options-indicator></more-options-indicator></td>
|
<td colspan="2"><more-options-indicator></more-options-indicator></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tbody v-show="moreOptionsVisible">
|
<tbody v-show="moreOptionsVisible">
|
||||||
|
<tr>
|
||||||
|
<td>专属域名</td>
|
||||||
|
<td>
|
||||||
|
<domains-box></domains-box>
|
||||||
|
<p class="comment">默认不需要填写,表示支持所有域名。如果填写了专属域名,表示当前路由规则只会在这些域名被访问时才生效。</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>不区分大小写</td>
|
<td>不区分大小写</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
@@ -52,6 +52,14 @@
|
|||||||
<td colspan="2"><more-options-indicator></more-options-indicator></td>
|
<td colspan="2"><more-options-indicator></more-options-indicator></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tbody v-show="moreOptionsVisible">
|
<tbody v-show="moreOptionsVisible">
|
||||||
|
<tr>
|
||||||
|
<td>专属域名</td>
|
||||||
|
<td>
|
||||||
|
<domains-box :v-domains="domains"></domains-box>
|
||||||
|
<p class="comment">默认不需要填写,表示支持所有域名。如果填写了专属域名,表示当前路由规则只会在这些域名被访问时才生效。</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>不区分大小写</td>
|
<td>不区分大小写</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
Reference in New Issue
Block a user