<script setup>
import PopupLayout from "@/layouts/PopupLayout.vue";
import ctxRef from "@/utils/ctx_ref.js";
import Context from "./createPopup.js"
import PostForm from "@/components/form/PostForm.vue";
import SubmitButton from "@/components/form/SubmitButton.vue";
import HTTPCacheRefBox from "@/components/server/HTTPCacheRefBox.vue"
import DefinitionTable from "@/components/common/DefinitionTable.vue";

const ctx = ctxRef(new Context())

</script>

<template>
	<PopupLayout>
		<header v-if="!ctx.isReverse && ctx.cacheRef == null">添加缓存条件</header>
		<header v-if="!ctx.isReverse && ctx.cacheRef != null">修改缓存条件</header>
		<header v-if="ctx.isReverse && ctx.cacheRef == null">添加不缓存条件</header>
		<header v-if="ctx.isReverse && ctx.cacheRef != null">修改不缓存条件</header>
		<PostForm action="$" @success="ctx.success">
			<DefinitionTable>
				<component :is="HTTPCacheRefBox" :v-cache-ref="ctx.cacheRef" :v-is-reverse="ctx.isReverse"></component>
			</DefinitionTable>
			<p class="comment" v-if="ctx.isReverse">如果请求满足当前添加的条件，则不缓存。</p>
			<SubmitButton>确定</SubmitButton>
		</PostForm>
	</PopupLayout>
</template>

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