<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 "./index.js"
import ServerSettingLayout from "@/layouts/ServerSettingLayout.vue";
import ServerFeatureRequired from "@/components/server/ServerFeatureRequired.vue";
import HTTPRewriteRuleList from "@/components/server/HTTPRewriteRuleList.vue";
import NavTab from "@/components/common/NavTab.vue";
import Navbar from "@/components/common/Navbar.vue";

const ctx = ctxRef(new Context())

</script>

<template>
	<ServerSettingLayout :ctx="ctx">
		<div v-if="ctx.featureIsOn">
			<Navbar secondary>
				<template #tabs>
					<NavTab :href="'.?serverId=' + ctx.serverId" name="重写规则列表" active></NavTab>
					<NavTab separator></NavTab>
					<NavTab @click.prevent="ctx.createRewriteRule()" name="创建重写规则" action-create></NavTab>
				</template>
			</Navbar>
			<HTTPRewriteRuleList :v-web-id="ctx.webId" :v-rewrite-rules="ctx.rewriteRules"></HTTPRewriteRuleList>
		</div>
		<div v-if="!ctx.featureIsOn">
			<ServerFeatureRequired></ServerFeatureRequired>
		</div>
	</ServerSettingLayout>
</template>

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