<template>
	<view class="gradient-header">
		<view class="back-btn" hover-class="hover_btn" @click="onBack">
			<image class="back-icon" src="/static/icon_back.png" mode="aspectFill"></image>
		</view>
		<text class="header-title">
			<slot>{{ title }}</slot>
		</text>
		<view style="width: 50rpx;"></view>
	</view>
</template>

<script setup lang="uts">
	type Props = {
		title : string
	}

	const props = withDefaults(defineProps<Props>(), {
		title: ''
	})

	const emit = defineEmits<{
		(e : 'back') : void
	}>()

	const onBack = () : void => {
		// 触发返回事件，由父组件决定返回逻辑，避免重复返回
		emit('back')
	}
</script>

<style>
	.gradient-header {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		padding: 0 36rpx;
		padding-top: 56rpx;
		height: 25%;
		background: linear-gradient(to bottom, #FC81C0, #FFFFFF);
	}

	.back-btn {
		width: 50rpx;
		height: 50rpx;
		border-radius: 25rpx;
		background-color: rgba(255, 255, 255, 0.5);
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.back-icon {
		width: 45rpx;
		height: 45rpx;
	}

	.header-title {
		font-weight: bold;
		font-size: 25rpx;
		color: #000000;
	}
</style>