mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 13:10:26 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			63 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			63 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
Vue.component("http-cache-config-box", {
 | 
						|
	props: ["v-cache-config", "v-is-location", "v-cache-policy"],
 | 
						|
	data: function () {
 | 
						|
		let cacheConfig = this.vCacheConfig
 | 
						|
		if (cacheConfig == null) {
 | 
						|
			cacheConfig = {
 | 
						|
				isPrior: false,
 | 
						|
				isOn: false,
 | 
						|
				addStatusHeader: true,
 | 
						|
				cacheRefs: []
 | 
						|
			}
 | 
						|
		}
 | 
						|
		return {
 | 
						|
			cacheConfig: cacheConfig
 | 
						|
		}
 | 
						|
	},
 | 
						|
	methods: {
 | 
						|
		isOn: function () {
 | 
						|
			return (!this.vIsLocation || this.cacheConfig.isPrior) && this.cacheConfig.isOn
 | 
						|
		}
 | 
						|
	},
 | 
						|
	template: `<div>
 | 
						|
	<input type="hidden" name="cacheJSON" :value="JSON.stringify(cacheConfig)"/>
 | 
						|
	<table class="ui table definition selectable">
 | 
						|
		<prior-checkbox :v-config="cacheConfig" v-if="vIsLocation"></prior-checkbox>
 | 
						|
		<tbody v-show="!vIsLocation || cacheConfig.isPrior">
 | 
						|
			<tr>
 | 
						|
				<td>缓存策略</td>
 | 
						|
				<td>
 | 
						|
					<div v-if="vCachePolicy != null">{{vCachePolicy.name}} <link-icon :href="'/servers/components/cache/policy?cachePolicyId=' + vCachePolicy.id"></link-icon>
 | 
						|
						<p class="comment">使用当前服务所在集群的设置。</p>
 | 
						|
					</div>
 | 
						|
					<span v-else class="red">当前集群没有设置缓存策略,当前配置无法生效。</span>
 | 
						|
				</td>
 | 
						|
			</tr>
 | 
						|
			<tr>
 | 
						|
				<td class="title">是否开启缓存</td>
 | 
						|
				<td>
 | 
						|
					<div class="ui checkbox">
 | 
						|
						<input type="checkbox" v-model="cacheConfig.isOn"/>
 | 
						|
						<label></label>
 | 
						|
					</div>
 | 
						|
				</td>
 | 
						|
			</tr>
 | 
						|
		</tbody>
 | 
						|
		<tbody v-show="isOn()">
 | 
						|
			<tr>
 | 
						|
				<td>自动添加X-Cache Header</td>
 | 
						|
				<td>
 | 
						|
					<checkbox v-model="cacheConfig.addStatusHeader"></checkbox>
 | 
						|
					<p class="comment">选中后自动在响应Header中增加<code-label>X-Cache: BYPASS|MISS|HIT</code-label>。</p>
 | 
						|
				</td>
 | 
						|
			</tr>
 | 
						|
		</tbody>
 | 
						|
	</table>
 | 
						|
	
 | 
						|
	<div v-show="isOn()">
 | 
						|
		<h4>缓存条件</h4>
 | 
						|
		<http-cache-refs-config-box :v-cache-config="cacheConfig" :v-cache-refs="cacheConfig.cacheRefs"></http-cache-refs-config-box>
 | 
						|
	</div>
 | 
						|
	<div class="margin"></div>
 | 
						|
</div>`
 | 
						|
}) |