mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 05:00:25 +08:00 
			
		
		
		
	优化缓存策略--“清理“功能
This commit is contained in:
		@@ -4,7 +4,7 @@
 | 
			
		||||
	<menu-item :href="'/servers/components/cache/policy?cachePolicyId=' + cachePolicyId" code="index">{{cachePolicyName}}</menu-item>
 | 
			
		||||
	<menu-item :href="'/servers/components/cache/test?cachePolicyId=' + cachePolicyId" code="test">测试</menu-item>
 | 
			
		||||
	<menu-item :href="'/servers/components/cache/stat?cachePolicyId=' + cachePolicyId" code="stat">统计</menu-item>
 | 
			
		||||
	<!--<menu-item :href="'/servers/components/cache/clean?cachePolicyId=' + cachePolicyId" code="clean">清理</menu-item>-->
 | 
			
		||||
	<menu-item :href="'/servers/components/cache/clean?cachePolicyId=' + cachePolicyId" code="clean">清理</menu-item>
 | 
			
		||||
	<menu-item :href="'/servers/components/cache/purge?cachePolicyId=' + cachePolicyId" code="purge">刷新</menu-item>
 | 
			
		||||
	<menu-item :href="'/servers/components/cache/fetch?cachePolicyId=' + cachePolicyId" code="fetch">预热</menu-item>
 | 
			
		||||
	<menu-item :href="'/servers/components/cache/update?cachePolicyId=' + cachePolicyId" code="update">修改</menu-item>
 | 
			
		||||
 
 | 
			
		||||
@@ -23,7 +23,7 @@
 | 
			
		||||
            <td>
 | 
			
		||||
                <textarea name="keys" rows="20" ref="keysBox"></textarea>
 | 
			
		||||
                <p class="comment" v-if="keyType == 'key'">每行一个URL,比如<code-label>https://example.com/hello/world.html</code-label>。</p>
 | 
			
		||||
                <p class="comment" v-if="keyType == 'prefix'">每行一个URL目录,比如<code-label>https://example.com/hello/</code-label>。</p>
 | 
			
		||||
                <p class="comment" v-if="keyType == 'prefix'">每行一个URL目录,比如<code-label>https://example.com/hello/</code-label>;如果只填写域名部分,表示清理全站,比如<code-label>https://example.com/</code-label>。</p>
 | 
			
		||||
            </td>
 | 
			
		||||
        </tr>
 | 
			
		||||
        <tr>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,31 +1,74 @@
 | 
			
		||||
{$layout}
 | 
			
		||||
 | 
			
		||||
	{$template "policy_menu"}
 | 
			
		||||
{$template "policy_menu"}
 | 
			
		||||
 | 
			
		||||
	<h3>选择集群</h3>
 | 
			
		||||
	<select class="ui dropdown auto-width" v-model="clusterId">
 | 
			
		||||
		<option v-for="cluster in clusters" :value="cluster.id">{{cluster.name}}</option>
 | 
			
		||||
	</select>
 | 
			
		||||
	<div class="ui divider"></div>
 | 
			
		||||
<h3>选择集群</h3>
 | 
			
		||||
<select class="ui dropdown auto-width" v-model="clusterId">
 | 
			
		||||
    <option v-for="cluster in clusters" :value="cluster.id">{{cluster.name}}</option>
 | 
			
		||||
</select>
 | 
			
		||||
<div class="ui divider"></div>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	<h3>清理</h3>
 | 
			
		||||
	<p class=""><span class="red">严重注意:该操作将清理集群所有节点上的所有对应缓存。</span></p>
 | 
			
		||||
	<form method="post" data-tea-action="$" data-tea-before="before" data-tea-success="success" data-tea-fail="fail" data-tea-done="done" data-tea-timeout="300">
 | 
			
		||||
		<input type="hidden" name="cachePolicyId" :value="cachePolicyId"/>
 | 
			
		||||
		<input type="hidden" name="clusterId" :value="clusterId"/>
 | 
			
		||||
		<table class="ui table definition selectable">
 | 
			
		||||
			<tr>
 | 
			
		||||
				<td class="title">操作结果</td>
 | 
			
		||||
				<td>
 | 
			
		||||
					<div v-if="isRequesting">数据发送中...</div>
 | 
			
		||||
					<span class="red" v-if="!isRequesting && !isOk && message.length > 0">失败:{{message}}</span>
 | 
			
		||||
					<div v-if="!isRequesting && isOk">
 | 
			
		||||
						<span v-if="results.length == 0" class="red">此集群下没有任何可用的节点。</span>
 | 
			
		||||
						<div class="ui label tiny" v-for="one in results" :class="{green:one.isOk, red:!one.isOk}" style="margin-bottom: 0.5em">{{one.nodeName}}:{{one.message}}</div>
 | 
			
		||||
					</div>
 | 
			
		||||
				</td>
 | 
			
		||||
			</tr>
 | 
			
		||||
		</table>
 | 
			
		||||
		<submit-btn v-if="!isRequesting">提交</submit-btn>
 | 
			
		||||
	</form>
 | 
			
		||||
<h3>清理</h3>
 | 
			
		||||
<p class=""><span class="red">严重警告:该操作将清理集群所有节点上的所有当前策略产生的缓存;如果只是想清理单个缓存,请使用“刷新预热”功能。</span></p>
 | 
			
		||||
<form method="post" data-tea-action="$" data-tea-before="before" data-tea-success="success" data-tea-fail="fail" data-tea-done="done" data-tea-timeout="300">
 | 
			
		||||
    <input type="hidden" name="cachePolicyId" :value="cachePolicyId"/>
 | 
			
		||||
    <input type="hidden" name="clusterId" :value="clusterId"/>
 | 
			
		||||
    <table class="ui table definition selectable">
 | 
			
		||||
        <tr>
 | 
			
		||||
            <td class="title">操作原因 *</td>
 | 
			
		||||
            <td>
 | 
			
		||||
                <p class="comment">为了防止新手滥用此功能、导致节点崩溃,你需要选择操作原因,才能继续操作:</p>
 | 
			
		||||
                <div>
 | 
			
		||||
                    <radio v-model="reason" :v-value="REASON_NEW_PIE">我是一名新手,我不知道怎么清除缓存</radio>
 | 
			
		||||
                </div>
 | 
			
		||||
                <div style="margin-top: 0.6em">
 | 
			
		||||
                    <radio v-model="reason" :v-value="REASON_BATCH_DELETE">要清理的域名太多,我比较懒,我不想用“刷新预热”功能</radio>
 | 
			
		||||
                </div>
 | 
			
		||||
                <div style="margin-top: 0.6em">
 | 
			
		||||
                    <radio v-model="reason" :v-value="REASON_MAINTAINS">因节点磁盘空间不足或以往缓存设置错误或其他原因,想清除所有缓存,重新开始</radio>
 | 
			
		||||
                </div>
 | 
			
		||||
                <div style="margin-top: 0.6em">
 | 
			
		||||
                    <radio v-model="reason" :v-value="REASON_ISSUE_REPORT">我怀疑“刷新预热”功能不起作用</radio>
 | 
			
		||||
                </div>
 | 
			
		||||
            </td>
 | 
			
		||||
        </tr>
 | 
			
		||||
        <tr v-show="!isReasonable()">
 | 
			
		||||
            <td>新手操作建议</td>
 | 
			
		||||
            <td>
 | 
			
		||||
                请使用左侧主菜单中的 <a href="/servers/components/cache/batch?keyType=prefix" target="_blank">[刷新预热]</a> 功能来清理你的缓存。
 | 
			
		||||
            </td>
 | 
			
		||||
        </tr>
 | 
			
		||||
        <tr v-show="reason == REASON_ISSUE_REPORT">
 | 
			
		||||
            <td>操作建议</td>
 | 
			
		||||
            <td>
 | 
			
		||||
                本产品提供的 <a href="/servers/components/cache/batch?keyType=prefix" target="_blank">[刷新预热]</a> 功能运行非常可靠,如果你确认发现功能异常,且能100%几率重现问题,请及时报告给软件开发者。
 | 
			
		||||
            </td>
 | 
			
		||||
        </tr>
 | 
			
		||||
        <tr v-show="reason == REASON_BATCH_DELETE">
 | 
			
		||||
            <td>操作建议</td>
 | 
			
		||||
            <td>
 | 
			
		||||
                请尽可能使用 <a href="/servers/components/cache/batch?keyType=prefix" target="_blank">[刷新预热]</a> 功能,避免影响当前系统上的别的网站。
 | 
			
		||||
            </td>
 | 
			
		||||
        </tr>
 | 
			
		||||
        <tr v-show="reason == REASON_MAINTAINS">
 | 
			
		||||
            <td>操作建议</td>
 | 
			
		||||
            <td>
 | 
			
		||||
                缓存文件较多时,系统需要消耗更多系统资源和更多时间删除缓存文件,磁盘使用空间会逐渐恢复,操作后,请耐心等待。
 | 
			
		||||
            </td>
 | 
			
		||||
        </tr>
 | 
			
		||||
        <tr v-show="isReasonable()">
 | 
			
		||||
            <td class="title">操作结果</td>
 | 
			
		||||
            <td>
 | 
			
		||||
                <div v-if="isRequesting">数据发送中...</div>
 | 
			
		||||
                <span class="red" v-if="!isRequesting && !isOk && message.length > 0">失败:{{message}}</span>
 | 
			
		||||
                <div v-if="!isRequesting && isOk">
 | 
			
		||||
                    <span v-if="results.length == 0" class="red">此集群下没有任何可用的节点。</span>
 | 
			
		||||
                    <div class="ui label tiny" v-for="one in results" :class="{green:one.isOk, red:!one.isOk}" style="margin-bottom: 0.5em">{{one.nodeName}}:{{one.message}}</div>
 | 
			
		||||
                </div>
 | 
			
		||||
            </td>
 | 
			
		||||
        </tr>
 | 
			
		||||
    </table>
 | 
			
		||||
    <submit-btn v-if="!isRequesting && isReasonable()">提交</submit-btn>
 | 
			
		||||
    <button class="ui button disabled" type="button" v-if="!isReasonable()">提交</button>
 | 
			
		||||
</form>
 | 
			
		||||
@@ -1,4 +1,15 @@
 | 
			
		||||
Tea.context(function () {
 | 
			
		||||
	this.reason = 0
 | 
			
		||||
 | 
			
		||||
	this.REASON_NEW_PIE = 0
 | 
			
		||||
	this.REASON_ISSUE_REPORT = 1
 | 
			
		||||
	this.REASON_BATCH_DELETE = 2
 | 
			
		||||
	this.REASON_MAINTAINS = 3
 | 
			
		||||
 | 
			
		||||
	this.isReasonable = function () {
 | 
			
		||||
		return this.reason == this.REASON_ISSUE_REPORT || this.reason == this.REASON_BATCH_DELETE || this.reason == this.REASON_MAINTAINS
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (this.clusterId == null) {
 | 
			
		||||
		if (this.clusters.length > 0) {
 | 
			
		||||
			this.clusterId = this.clusters[0].id
 | 
			
		||||
 
 | 
			
		||||
@@ -20,7 +20,7 @@
 | 
			
		||||
            <td>
 | 
			
		||||
                <textarea name="keys" rows="10" ref="keysBox"></textarea>
 | 
			
		||||
                <p class="comment" v-if="keyType == 'key'">每行一个URL,比如<code-label>https://example.com/hello/world.html</code-label>。</p>
 | 
			
		||||
                <p class="comment" v-if="keyType == 'prefix'">每行一个URL目录,比如<code-label>https://example.com/hello/</code-label>。</p>
 | 
			
		||||
                <p class="comment" v-if="keyType == 'prefix'">每行一个URL目录,比如<code-label>https://example.com/hello/</code-label>;如果只填写域名部分,表示清理全站,比如<code-label>https://example.com/</code-label>。</p>
 | 
			
		||||
            </td>
 | 
			
		||||
        </tr>
 | 
			
		||||
        <tr>
 | 
			
		||||
 
 | 
			
		||||
@@ -30,7 +30,7 @@
 | 
			
		||||
                    <td>
 | 
			
		||||
                        <textarea name="keys" rows="10" ref="keysBox"></textarea>
 | 
			
		||||
                        <p class="comment" v-if="keyType == 'key'">每行一个URL,比如<code-label>https://example.com/hello/world.html</code-label>。</p>
 | 
			
		||||
                        <p class="comment" v-if="keyType == 'prefix'">每行一个URL目录,比如<code-label>https://example.com/hello/</code-label>。</p>
 | 
			
		||||
                        <p class="comment" v-if="keyType == 'prefix'">每行一个URL目录,比如<code-label>https://example.com/hello/</code-label>;如果只填写域名部分,表示清理全站,比如<code-label>https://example.com/</code-label>。</p>
 | 
			
		||||
                    </td>
 | 
			
		||||
                </tr>
 | 
			
		||||
                <tr>
 | 
			
		||||
 
 | 
			
		||||
@@ -31,7 +31,7 @@
 | 
			
		||||
                    <td>
 | 
			
		||||
                        <textarea name="keys" rows="10" ref="keysBox"></textarea>
 | 
			
		||||
                        <p class="comment" v-if="keyType == 'key'">每行一个URL,比如<code-label>https://example.com/hello/world.html</code-label>。</p>
 | 
			
		||||
                        <p class="comment" v-if="keyType == 'prefix'">每行一个URL目录,比如<code-label>https://example.com/hello/</code-label>。</p>
 | 
			
		||||
                        <p class="comment" v-if="keyType == 'prefix'">每行一个URL目录,比如<code-label>https://example.com/hello/</code-label>;如果只填写域名部分,表示清理全站,比如<code-label>https://example.com/</code-label>。</p>
 | 
			
		||||
                    </td>
 | 
			
		||||
                </tr>
 | 
			
		||||
                <tr>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user