mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-05 06:10:26 +08:00
实现缓存策略的部分功能
This commit is contained in:
@@ -72,6 +72,7 @@ func (this *IndexAction) RunPost(params struct {
|
|||||||
MinLength string
|
MinLength string
|
||||||
MaxLength string
|
MaxLength string
|
||||||
CondsJSON []byte
|
CondsJSON []byte
|
||||||
|
GzipRefJSON []byte
|
||||||
|
|
||||||
Must *actions.Must
|
Must *actions.Must
|
||||||
}) {
|
}) {
|
||||||
@@ -97,6 +98,13 @@ func (this *IndexAction) RunPost(params struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gzipRef := &serverconfigs.HTTPGzipRef{}
|
||||||
|
err := json.Unmarshal(params.GzipRefJSON, gzipRef)
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if params.GzipId > 0 {
|
if params.GzipId > 0 {
|
||||||
_, err := this.RPC().HTTPGzipRPC().UpdateHTTPGzip(this.AdminContext(), &pb.UpdateHTTPGzipRequest{
|
_, err := this.RPC().HTTPGzipRPC().UpdateHTTPGzip(this.AdminContext(), &pb.UpdateHTTPGzipRequest{
|
||||||
GzipId: params.GzipId,
|
GzipId: params.GzipId,
|
||||||
@@ -120,12 +128,9 @@ func (this *IndexAction) RunPost(params struct {
|
|||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
gzipId := resp.GzipId
|
gzipRef.GzipId = resp.GzipId
|
||||||
|
|
||||||
gzipRef := &serverconfigs.HTTPGzipRef{
|
|
||||||
IsOn: true,
|
|
||||||
GzipId: gzipId,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gzipRefJSON, err := json.Marshal(gzipRef)
|
gzipRefJSON, err := json.Marshal(gzipRef)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
@@ -139,7 +144,6 @@ func (this *IndexAction) RunPost(params struct {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
this.Success()
|
this.Success()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ Vue.component("http-cache-config-box", {
|
|||||||
<th class="two op">操作</th>
|
<th class="two op">操作</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-for="(cacheRef, index) in cacheConfig.cacheRefs">
|
<tr v-for="(cacheRef, index) in cacheConfig.cacheRefs">
|
||||||
<td>{{cacheRef.cachePolicy.name}}</td>
|
<td><a :href="'/servers/components/cache/policy?cachePolicyId=' + cacheRef.cachePolicyId">{{cacheRef.cachePolicy.name}}</a></td>
|
||||||
<td>
|
<td>
|
||||||
<http-request-conds-view :v-conds="cacheRef.conds"></http-request-conds-view>
|
<http-request-conds-view :v-conds="cacheRef.conds"></http-request-conds-view>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
Vue.component("http-location-labels", {
|
Vue.component("http-location-labels", {
|
||||||
props: ["v-location-config"],
|
props: ["v-location-config", "v-server-id"],
|
||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
location: this.vLocationConfig
|
location: this.vLocationConfig
|
||||||
@@ -17,32 +17,33 @@ Vue.component("http-location-labels", {
|
|||||||
|
|
||||||
len: function (arr) {
|
len: function (arr) {
|
||||||
return (arr == null) ? 0 : arr.length
|
return (arr == null) ? 0 : arr.length
|
||||||
|
},
|
||||||
|
url: function (path) {
|
||||||
|
return "/servers/server/settings/locations" + path + "?serverId=" + this.vServerId + "&locationId=" + this.location.id
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
template: ` <div class="labels-box">
|
template: ` <div class="labels-box">
|
||||||
<!-- TODO 思考是否给各个标签加上链接 -->
|
|
||||||
|
|
||||||
<!-- 基本信息 -->
|
<!-- 基本信息 -->
|
||||||
<http-location-labels-label v-if="location.name != null && location.name.length > 0" :class="'olive'">{{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>
|
||||||
<http-location-labels-label v-if="location.isBreak">BREAK</http-location-labels-label>
|
<http-location-labels-label v-if="location.isBreak" :href="url('/location')">BREAK</http-location-labels-label>
|
||||||
|
|
||||||
<!-- redirectToHTTPS -->
|
<!-- redirectToHTTPS -->
|
||||||
<http-location-labels-label v-if="location.web != null && configIsOn(location.web.redirectToHTTPS)">自动跳转HTTPS</http-location-labels-label>
|
<http-location-labels-label v-if="location.web != null && configIsOn(location.web.redirectToHTTPS)" :href="url('/http')">自动跳转HTTPS</http-location-labels-label>
|
||||||
|
|
||||||
<!-- Web -->
|
<!-- Web -->
|
||||||
<http-location-labels-label v-if="location.web != null && configIsOn(location.web.root)">文档根目录</http-location-labels-label>
|
<http-location-labels-label v-if="location.web != null && configIsOn(location.web.root)" :href="url('/web')">文档根目录</http-location-labels-label>
|
||||||
|
|
||||||
<!-- 反向代理 -->
|
<!-- 反向代理 -->
|
||||||
<http-location-labels-label v-if="refIsOn(location.reverseProxyRef, location.reverseProxy)">反向代理</http-location-labels-label>
|
<http-location-labels-label v-if="refIsOn(location.reverseProxyRef, location.reverseProxy)" :v-href="url('/reverseProxy')">反向代理</http-location-labels-label>
|
||||||
|
|
||||||
<!-- WAF -->
|
<!-- WAF -->
|
||||||
<!-- TODO -->
|
<!-- TODO -->
|
||||||
|
|
||||||
<!-- Cache -->
|
<!-- Cache -->
|
||||||
<!-- TODO -->
|
<http-location-labels-label v-if="location.web != null && configIsOn(location.web.cache)" :v-href="url('/cache')">CACHE</http-location-labels-label>
|
||||||
|
|
||||||
<!-- Charset -->
|
<!-- Charset -->
|
||||||
<http-location-labels-label v-if="location.web != null && configIsOn(location.web.charset) && location.web.charset.charset.length > 0">{{location.web.charset.charset}}</http-location-labels-label>
|
<http-location-labels-label v-if="location.web != null && configIsOn(location.web.charset) && location.web.charset.charset.length > 0" :href="url('/charset')">{{location.web.charset.charset}}</http-location-labels-label>
|
||||||
|
|
||||||
<!-- 访问日志 -->
|
<!-- 访问日志 -->
|
||||||
<!-- TODO -->
|
<!-- TODO -->
|
||||||
@@ -51,29 +52,33 @@ Vue.component("http-location-labels", {
|
|||||||
<!-- TODO -->
|
<!-- TODO -->
|
||||||
|
|
||||||
<!-- Gzip -->
|
<!-- Gzip -->
|
||||||
<http-location-labels-label v-if="location.web != null && refIsOn(location.web.gzipRef, location.web.gzip) && location.web.gzip.level > 0">Gzip:{{location.web.gzip.level}}</http-location-labels-label>
|
<http-location-labels-label v-if="location.web != null && refIsOn(location.web.gzipRef, location.web.gzip) && location.web.gzip.level > 0" :href="url('/gzip')">Gzip:{{location.web.gzip.level}}</http-location-labels-label>
|
||||||
|
|
||||||
<!-- HTTP Header -->
|
<!-- HTTP Header -->
|
||||||
<http-location-labels-label v-if="location.web != null && refIsOn(location.web.requestHeaderPolicyRef, location.web.requestHeaderPolicy) && (len(location.web.requestHeaderPolicy.addHeaders) > 0 || len(location.web.requestHeaderPolicy.setHeaders) > 0 || len(location.web.requestHeaderPolicy.replaceHeaders) > 0 || len(location.web.requestHeaderPolicy.deleteHeaders) > 0)">请求Header</http-location-labels-label>
|
<http-location-labels-label v-if="location.web != null && refIsOn(location.web.requestHeaderPolicyRef, location.web.requestHeaderPolicy) && (len(location.web.requestHeaderPolicy.addHeaders) > 0 || len(location.web.requestHeaderPolicy.setHeaders) > 0 || len(location.web.requestHeaderPolicy.replaceHeaders) > 0 || len(location.web.requestHeaderPolicy.deleteHeaders) > 0)" :href="url('/headers')">请求Header</http-location-labels-label>
|
||||||
<http-location-labels-label v-if="location.web != null && refIsOn(location.web.responseHeaderPolicyRef, location.web.responseHeaderPolicy) && (len(location.web.responseHeaderPolicy.addHeaders) > 0 || len(location.web.responseHeaderPolicy.setHeaders) > 0 || len(location.web.responseHeaderPolicy.replaceHeaders) > 0 || len(location.web.responseHeaderPolicy.deleteHeaders) > 0)">响应Header</http-location-labels-label>
|
<http-location-labels-label v-if="location.web != null && refIsOn(location.web.responseHeaderPolicyRef, location.web.responseHeaderPolicy) && (len(location.web.responseHeaderPolicy.addHeaders) > 0 || len(location.web.responseHeaderPolicy.setHeaders) > 0 || len(location.web.responseHeaderPolicy.replaceHeaders) > 0 || len(location.web.responseHeaderPolicy.deleteHeaders) > 0)" :href="url('/headers')">响应Header</http-location-labels-label>
|
||||||
|
|
||||||
<!-- Websocket -->
|
<!-- Websocket -->
|
||||||
<http-location-labels-label v-if="location.web != null && refIsOn(location.web.websocketRef, location.web.websocket)">Websocket</http-location-labels-label>
|
<http-location-labels-label v-if="location.web != null && refIsOn(location.web.websocketRef, location.web.websocket)" :href="url('/websocket')">Websocket</http-location-labels-label>
|
||||||
|
|
||||||
<!-- 特殊页面 -->
|
<!-- 特殊页面 -->
|
||||||
<div v-if="location.web != null && location.web.pages != null && location.web.pages.length > 0">
|
<div v-if="location.web != null && location.web.pages != null && location.web.pages.length > 0">
|
||||||
<div v-for="page in location.web.pages" :key="page.id"><http-location-labels-label>PAGE [状态码{{page.status[0]}}] -> {{page.url}}</http-location-labels-label></div>
|
<div v-for="page in location.web.pages" :key="page.id"><http-location-labels-label :href="url('/pages')">PAGE [状态码{{page.status[0]}}] -> {{page.url}}</http-location-labels-label></div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="location.web != null && configIsOn(location.web.shutdown)">
|
<div v-if="location.web != null && configIsOn(location.web.shutdown)">
|
||||||
<http-location-labels-label :v-class="'red'">临时关闭</http-location-labels-label>
|
<http-location-labels-label :v-class="'red'" :href="url('/pages')">临时关闭</http-location-labels-label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 重写规则 -->
|
<!-- 重写规则 -->
|
||||||
<!-- TODO -->
|
<div v-if="location.web != null && location.web.rewriteRules != null && location.web.rewriteRules.length > 0">
|
||||||
|
<div v-for="rewriteRule in location.web.rewriteRules">
|
||||||
|
<http-location-labels-label :href="url('/rewrite')">REWRITE {{rewriteRule.pattern}} -> {{rewriteRule.replace}}</http-location-labels-label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>`
|
</div>`
|
||||||
})
|
})
|
||||||
|
|
||||||
Vue.component("http-location-labels-label", {
|
Vue.component("http-location-labels-label", {
|
||||||
props: ["v-class"],
|
props: ["v-class", "v-href"],
|
||||||
template: `<span class="ui label tiny" :class="vClass" style="font-size:0.7em;padding:4px;margin-top:0.3em;margin-bottom:0.3em"><slot></slot></span>`
|
template: `<a :href="vHref" class="ui label tiny" :class="vClass" style="font-size:0.7em;padding:4px;margin-top:0.3em;margin-bottom:0.3em"><slot></slot></a>`
|
||||||
})
|
})
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
<td><i class="icon bars grey handle"></i></td>
|
<td><i class="icon bars grey handle"></i></td>
|
||||||
<td>
|
<td>
|
||||||
{{location.pattern}}
|
{{location.pattern}}
|
||||||
<http-location-labels :v-location-config="location"></http-location-labels>
|
<http-location-labels :v-location-config="location" :v-server-id="serverId"></http-location-labels>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<label-on :v-is-on="location.isOn"></label-on>
|
<label-on :v-is-on="location.isOn"></label-on>
|
||||||
|
|||||||
Reference in New Issue
Block a user