<script setup>
import ServerConfigCopyLink from "@/components/server/ServerConfigCopyLink.vue";
import {ref} from "vue";
// import TDivider from "@/components/ui/TDivider.vue";
import TBreadcrumb from "@/components/ui/TBreadcrumb.vue";

const props = defineProps(["ctx"])

const navItems = ref([
	{
		name: "网站列表",
		url: "/servers",
		icon: "pi pi-home"
	},
	{
		name: props.ctx.server.name,
		url: "/servers/server?serverId=" + props.ctx.server.id
	}
])

if (props.ctx.leftMenuActiveItem != null) {
	navItems.value.push({
		name: "\"" + props.ctx.leftMenuActiveItem.name + "\"设置",
		url: props.ctx.leftMenuActiveItem.url,
		isLast: true
	})
} else {
	navItems.value.push({
		name: "\"" + props.ctx.server.name + "\"设置",
		url: "/servers/server/settings?serverId=" + props.ctx.server.id,
		isLast: true
	})
}
</script>

<template>
	<div>
		<TBreadcrumb :items="navItems" class="!py-0">
			<template #item="{item}">
				<span class="flex">
					<a :href="item.url" class="p-breadcrumb-item-link">
						<!-- <span class="p-breadcrumb-item-icon" v-if="item.icon" :class="item.icon" data-pc-section="itemicon"></span> -->
						<span class="p-breadcrumb-item-label">{{ item.name }}</span>
					</a>

					<span v-if="item.isLast" class="flex flex-row ml-4 gap-4">
						<span class="disabled item" style="font-size: 0.8em" v-if="ctx.leftMenuActiveItem != null && ctx.leftMenuActiveItem.configCode != null && ctx.leftMenuActiveItem.configCode.length > 0 && ctx.teaCommon.teaIsPlus">|</span>
						<ServerConfigCopyLink class="p-breadcrumb-item-link !gap-0" :v-server-id="ctx.server.id" :v-config-code="ctx.leftMenuActiveItem.configCode" v-if="ctx.leftMenuActiveItem != null && ctx.leftMenuActiveItem.configCode != null && ctx.leftMenuActiveItem.configCode.length > 0 && ctx.teaCommon.teaIsPlus"></ServerConfigCopyLink>
					</span>
				</span>
			</template>
		</TBreadcrumb>
		<!-- <TDivider></TDivider> -->
	</div>
</template>

<style scoped>
:deep(.p-breadcrumb) {
	background-color: #edeff4;
	padding: 0;
	margin-bottom: 12px;
	color: rgba(101, 112, 128, 1);
	font-family: Source Han Sans SC;
	font-weight: 400;
	font-size: 16px;
	line-height: 24px;
}
</style>