<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 ChildLayout from "@/layouts/ChildLayout.vue";
import WarningMessage from "@/components/common/WarningMessage.vue";
import PostForm from "@/components/form/PostForm.vue";
import SubmitButton from "@/components/form/SubmitButton.vue";
import TLabel from "@/components/ui/TLabel.vue";
import NetworkAddressesBox from "@/components/common/NetworkAddressesBox.vue";
import DefinitionTable from "@/components/common/DefinitionTable.vue";

const ctx = ctxRef(new Context())

</script>

<template>
	<ChildLayout :ctx="ctx" :has-tab="true">
		<div v-if="!ctx.canSpecifyPort">
			<WarningMessage>根据系统管理员设定，你不能修改此网站的端口信息。</WarningMessage>
		</div>
		<PostForm action="$" @success="ctx.success">
			<input type="hidden" name="serverId" :value="ctx.serverId"/>
			<input type="hidden" name="serverType" :value="ctx.serverType"/>
			<DefinitionTable>
				<tbody>
				<tr>
					<td class="title">绑定端口 *</td>
					<td>
						<div v-show="ctx.canSpecifyPort">
							<NetworkAddressesBox :v-server-type="ctx.serverType" :v-addresses="ctx.tcpConfig.listen" :v-protocol="'tcp'"></NetworkAddressesBox>
						</div>
						<div v-show="!ctx.canSpecifyPort" v-if="ctx.tcpConfig.listen != null" class="label-group">
							<TLabel outlined="" v-for="listen in ctx.tcpConfig.listen">tcp://*:{{ listen.portRange }}</TLabel>
						</div>
					</td>
				</tr>
				</tbody>
			</DefinitionTable>
			<SubmitButton></SubmitButton>
		</PostForm>
	</ChildLayout>
</template>

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