实现缓存策略的部分功能

This commit is contained in:
GoEdgeLab
2020-10-05 16:54:34 +08:00
parent 0bbd178b29
commit 48ad7cded8
4 changed files with 53 additions and 44 deletions

View File

@@ -108,7 +108,7 @@ Vue.component("http-cache-config-box", {
<th class="two op">操作</th>
</tr>
<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>
<http-request-conds-view :v-conds="cacheRef.conds"></http-request-conds-view>
</td>

View File

@@ -1,5 +1,5 @@
Vue.component("http-location-labels", {
props: ["v-location-config"],
props: ["v-location-config", "v-server-id"],
data: function () {
return {
location: this.vLocationConfig
@@ -17,32 +17,33 @@ Vue.component("http-location-labels", {
len: function (arr) {
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">
<!-- 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.isBreak">BREAK</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" :href="url('/location')">BREAK</http-location-labels-label>
<!-- 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 -->
<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 -->
<!-- TODO -->
<!-- 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 -->
<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 -->
@@ -51,29 +52,33 @@ Vue.component("http-location-labels", {
<!-- TODO -->
<!-- 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-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.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.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)" :href="url('/headers')">响应Header</http-location-labels-label>
<!-- 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-for="page in location.web.pages" :key="page.id"><http-location-labels-label>PAGE [状态码{{page.status[0]}}] -&gt; {{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]}}] -&gt; {{page.url}}</http-location-labels-label></div>
</div>
<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>
<!-- 重写规则 -->
<!-- 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}} -&gt; {{rewriteRule.replace}}</http-location-labels-label>
</div>
</div>
</div>`
})
Vue.component("http-location-labels-label", {
props: ["v-class"],
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>`
props: ["v-class", "v-href"],
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>`
})

View File

@@ -24,7 +24,7 @@
<td><i class="icon bars grey handle"></i></td>
<td>
{{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>
<label-on :v-is-on="location.isOn"></label-on>