<script setup>

import {ref} from "vue"
import ScriptGroupConfigBox from "@/components/server/ScriptGroupConfigBox.vue";

const props = defineProps(["vRequestScriptsConfig", "v-auditing-status", "v-is-location"])

const {config} = (function () {
	let config = props.vRequestScriptsConfig
	if (config == null) {
		config = {}
	}

	return {
		config: ref(config)
	}
})()

const changeInitGroup = function (group) {
	config.value.initGroup = group
}

const changeRequestGroup = function (group) {
	config.value.requestGroup = group
}

</script>

<template>
	<div>
		<input type="hidden" name="requestScriptsJSON" :value="JSON.stringify(config)"/>
		<h5 class="!mb-4">请求初始化</h5>
		<p class="comment">在请求刚初始化时调用，此时自定义报头等尚未生效。</p>
		<div>
			<ScriptGroupConfigBox :v-group="config.initGroup" :v-auditing-status="vAuditingStatus" @change="changeInitGroup" :v-is-location="vIsLocation"></ScriptGroupConfigBox>
		</div>
		<h5 class="group-header">准备发送请求</h5>
		<p class="comment">在准备执行请求或者转发请求之前调用，此时自定义报头、源站等已准备好。</p>
		<div>
			<ScriptGroupConfigBox :v-group="config.requestGroup" :v-auditing-status="vAuditingStatus" @change="changeRequestGroup" :v-is-location="vIsLocation"></ScriptGroupConfigBox>
		</div>
	</div>
</template>

<style scoped>
</style>
