<template>
    <div class="fishing-log">
        <h2>钓鱼日志</h2>
        <el-scrollbar height="300px">
            <div v-if="logs.length > 0" class="log-list">
                <div v-for="(log, index) in logs" :key="index" class="log-item" :class="{ rare: log.isRare }">
                    <div class="log-time">{{ formatTime(log.time) }}</div>
                    <div class="log-content">
                        <el-tag :type="log.isRare ? 'warning' : 'info'" effect="plain">
                            {{ log.fishName }}
                        </el-tag>
                        <span class="log-weight">{{ log.weight }}</span>
                    </div>
                </div>
            </div>
            <el-empty v-else description="暂无钓鱼记录" />
        </el-scrollbar>
    </div>
</template>

<script setup>
import { ref } from 'vue'

const props = defineProps({
    logs: {
        type: Array,
        default: () => []
    }
})

const formatTime = (time) => {
    return new Date(time).toLocaleString()
}
</script>

<style scoped>
.fishing-log {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}

.log-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.log-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-radius: 4px;
    background: #f5f7fa;
    transition: all 0.3s ease;
}

.log-item:hover {
    transform: translateX(5px);
    background: #ecf5ff;
}

.log-time {
    color: #909399;
    font-size: 14px;
}

.log-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.log-weight {
    color: #606266;
}

.rare {
    background: #fdf6ec;
}

.rare:hover {
    background: #faecd8;
}
</style>