<template>
	<div id="home-page">
		<IntegratedLayout>
			<div class="top-title">
				<div class="first-text">
					AIToolsFinder
				</div>
				<div class="second-text">
					Get global AI tools in one stop
				</div>
				<div class="third-text">
					It includes over a <a href="/" class="special">thousand global AI tools</a>, covering writing, images,
					videos, audio, programming,
					music, design, chatting, etc, and recommends learning platforms, frameworks and models
				</div>
				<!-- 修改输入框容器 -->
				<div class="margin-62">
					<SearchSelectInput />
				</div>
			</div>

			<div class="card flex">
				<div class="left-card card-box">
					<el-carousel :autoplay="false" autoplay :interval="8000">
						<el-carousel-item v-for="(item, i) in banner" :key="i">
							<div class="img-cover">
								<img :src="item.imageUrl || ''" alt="" class="img" />
							</div>
						</el-carousel-item>
					</el-carousel>
				</div>
				<div class="right-card card-box">
					<PopularToolList />
				</div>
			</div>
			<NuxtChild />
		</IntegratedLayout>
	</div>
</template>

<script>
import PopularToolList from "@/pages/Home/components/PopularToolList.vue";
import GlobalLoading from "@/components/GlobalLoading.vue";

export default {
	name: 'Home',
	components: {
		PopularToolList,
		GlobalLoading,
	},
	computed: {
		banner() {
			const bannerConfig = this.$store.getters.bannerConfig;
			if (bannerConfig.home && bannerConfig.home.length > 0) {
				return bannerConfig.home;
			}
			return [];
		}
	},
	data() {
		return {}
	},
	methods: {
	},
	watch: {
		'$route'() {
			// 当路由变化时滚动到顶部
			window.scrollTo(0, 0);
		}
	},
	mounted() {
		this.$store.dispatch('getBannerConfig');
	}
}
</script>

<style lang="scss" scoped>
.img-cover {
	height: 100%; width: 100%; padding: 24px 20px 30px;
}
.img {
	height: 100%;
	width: 100%;
	border-radius: 12px;
}
.margin-62 {
	margin: 40px auto 40px;
}
#home-page {
	flex: 1;
	overflow-y: auto; // 必须启用滚动
	position: relative; // 添加相对定位
	background-repeat: no-repeat;
	background-size: contain; // 控制图片自适应
	background-position: top center;
	background-image: url('/logo/mask.png');
}

.top-title {
	@include flex-center;
	flex-direction: column;
	font-weight: bold;
	margin-top: 120px;

	div {
		text-align: center;
	}

	.first-text {
		line-height: 90px;
		font-size: $huge-font-size3;
		font-family: 'Poppins-ExtraBold';
		@include text-gradient(90deg, #2563eb, 22%, #7B61FF, 73%);
	}

	.second-text {
		margin: 18px 0;
		font-family: 'Poppins-Bold';
		font-size: $huge-font-size2;
		line-height: 75px;
	}

	.third-text {
		width: 716px;
		color: $grey-color;
		font-size: $normal-font-size;
		margin-top: 8px;
		font-family: 'Poppins-Medium';

		.special {
			color: $main-color;
		}
	}
}

.card {
	display: grid;
	grid-template-columns: 2fr 1fr; // 4列布局
	gap: 11px; // 网格间距
	margin: 0 auto;

	.card-box {
		background: $white;
		box-shadow: 0 18px 33px 0 rgba(0, 0, 0, 0.05);
		border-radius: 12px;
		border: 1px solid #FFFFFF;
	}

	.left-card {
		// min-width: 805px;
		overflow: hidden;
		box-sizing: border-box;
		::v-deep .el-carousel {
			.el-carousel__container {
				height: 354px;
			}
			.el-carousel__arrow {
				opacity: 0 !important;
				transition: none !important;
			}
			.el-carousel__indicators {
				.el-carousel__indicator {
					height: 4px !important;
					width: 12px !important;
					border-radius: 2.66px !important;
					border: 0.66px solid #2563eb !important;
					background: transparent !important;
					margin: 0 3px 0 3px !important;
					padding: 0 !important;

					.el-carousel__button {
						background-color: transparent;
					}

					&.is-active {
						border: none !important;
						width: 20px !important;
						background: linear-gradient(0deg, #2563EB 22%, #7B61FF 73%) !important;
					}

					// 重置其他可能的默认样式
					&:before,
					&:after {
						display: none !important;
					}
				}
			}
		}
	}

	.right-card {
		padding: 20px;
		max-width: 372px;
	}
}
</style>
