<script setup>
// Copyright 2024 FlexCDN root@flexcdn.cn. All rights reserved. Official site: https://flexcdn.cn .

import ctxRef from "@/utils/ctx_ref.js"
import Context from "./fetch.js"
import TTextarea from "@/components/ui/TTextarea.vue";
import PostForm from "@/components/form/PostForm.vue";
import SubmitButton from "@/components/form/SubmitButton.vue";
import TButton from "@/components/ui/TButton.vue";
import Menu from "@/views/servers/cache/@menu.vue";
import DefinitionTable from "@/components/common/DefinitionTable.vue";

const ctx = ctxRef(new Context())

</script>

<template>
	<Menu :ctx="ctx" active-tab="fetch"></Menu>

	<div><span class="grey">预热缓存指的是预先从源站读取最新内容，当用户访问预热后的URL时直接从缓存中返回内容，不需要再次回源。</span></div>

	<PostForm action="$" @success="ctx.success" @done="ctx.done" timeout="600" @before="ctx.before" class="mt-4">
		<DefinitionTable>
			<tbody>
			<tr>
				<td class="title">
					URL列表 *
				</td>
				<td>
					<TTextarea rows="20" name="urlList" autofocus class="w-full"></TTextarea>
					<p class="comment">每行一条，每次最多提交{{ctx.maxKeysPerTask}}个URL，每天最多提交{{ctx.maxKeysPerDay}}个<span v-if="ctx.quotaKeysToday > 0">，今日剩余{{ctx.quotaKeysToday}}个</span>。</p>
				</td>
			</tr>
			</tbody>
		</DefinitionTable>
		<SubmitButton v-if="!ctx.isRequesting">预热缓存</SubmitButton>
		<TButton disabled type="button" v-if="ctx.isRequesting">处理中...</TButton>
	</PostForm>
</template>

<style lang="postcss" scoped>
</style>