<template>
  <div class="home-container">
    <!-- 英雄区域 -->
    <section class="hero-section">
      <div class="hero-content">
        <h1>智能算法展示平台</h1>
        <p>通过「仿真输入 - 一键调用 - 效果可视化」快速感知算法价值</p>
        <div class="hero-buttons">
          <router-link to="/algorithms" class="primary-btn">浏览算法</router-link>
          <router-link to="/register" class="secondary-btn">注册体验</router-link>
        </div>
      </div>
    </section>
    
    <!-- 核心功能 -->
    <section class="features-section">
      <h2>核心功能</h2>
      <div class="features-grid">
        <div class="feature-card">
          <div class="feature-icon">
            <el-icon class="icon"><data-analysis /></el-icon>
          </div>
          <h3>算法API封装调用</h3>
          <p>将所有算法封装成统一的API接口，支持一键调用，方便快捷</p>
        </div>
        <div class="feature-card">
          <div class="feature-icon">
            <el-icon class="icon"><chat-dot-round /></el-icon>
          </div>
          <h3>OpenAI仿真输入获取</h3>
          <p>集成OpenAI API，通过文本描述生成仿真输入数据，提高测试效率</p>
        </div>
        <div class="feature-card">
          <div class="feature-icon">
            <el-icon class="icon"><pie-chart /></el-icon>
          </div>
          <h3>多维度效果展示</h3>
          <p>支持图表、图像对比、数值分析等多种展示方式，直观呈现算法效果</p>
        </div>
      </div>
    </section>
    
    <!-- 热门算法 -->
    <section class="algorithms-section">
      <div class="section-header">
        <h2>热门算法</h2>
        <router-link to="/algorithms" class="view-all">查看全部</router-link>
      </div>
      
      <div class="algorithms-grid">
        <div v-for="algorithm in popularAlgorithms" :key="algorithm.id" class="algorithm-card">
          <h3>{{ algorithm.name }}</h3>
          <p class="algorithm-type">{{ algorithm.type }}</p>
          <p class="algorithm-desc">{{ algorithm.description }}</p>
          <div class="algorithm-actions">
            <router-link :to="`/algorithm/${algorithm.id}`" class="detail-btn">查看详情</router-link>
            <router-link :to="`/algorithm/${algorithm.id}/call`" class="call-btn">立即调用</router-link>
          </div>
        </div>
      </div>
    </section>
  </div>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { useAlgorithmStore } from '../stores/algorithm'
import { DataAnalysis, ChatDotRound, PieChart } from '@element-plus/icons-vue'

// 模拟热门算法数据
const popularAlgorithms = ref([
  {
    id: 'algorithm-001',
    name: '图像分类算法',
    type: 'computer_vision',
    description: '基于深度学习的图像分类算法，支持多种物体类别的识别'
  },
  {
    id: 'algorithm-002',
    name: '目标识别',
    type: 'computer_vision',
    description: '识别图像中的物体位置和类别，支持人脸、车辆、物品等多种目标检测'
  },
  {
    id: 'algorithm-003',
    name: '视频分析',
    type: 'video_processing',
    description: '分析视频内容，提取关键帧、识别动作、追踪物体等'
  }
])
</script>

<style scoped>
.home-container {
  max-width: 1200px;
  margin: 0 auto;
}

/* 英雄区域 */
.hero-section {
  background: linear-gradient(135deg, #409EFF 0%, #667EEA 100%);
  color: #fff;
  padding: 100px 20px;
  text-align: center;
  border-radius: 12px;
  margin-bottom: 40px;
}

.hero-content h1 {
  font-size: 48px;
  margin-bottom: 20px;
  font-weight: bold;
}

.hero-content p {
  font-size: 18px;
  margin-bottom: 30px;
  opacity: 0.9;
}

.hero-buttons {
  display: flex;
  justify-content: center;
  gap: 20px;
}

.primary-btn,
.secondary-btn {
  padding: 12px 24px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 16px;
  font-weight: 500;
  transition: all 0.3s ease;
}

.primary-btn {
  background-color: #fff;
  color: #409EFF;
}

.primary-btn:hover {
  background-color: #f5f7fa;
  transform: translateY(-2px);
}

.secondary-btn {
  background-color: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.secondary-btn:hover {
  background-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

/* 功能区域 */
.features-section {
  margin-bottom: 60px;
}

.features-section h2 {
  text-align: center;
  font-size: 32px;
  margin-bottom: 40px;
  color: #333;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 30px;
}

.feature-card {
  background-color: #fff;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  text-align: center;
  transition: all 0.3s ease;
}

.feature-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.feature-icon {
  width: 80px;
  height: 80px;
  background-color: #ecf5ff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.feature-icon .icon {
  font-size: 40px;
  color: #409EFF;
}

.feature-card h3 {
  font-size: 20px;
  margin-bottom: 15px;
  color: #333;
}

.feature-card p {
  color: #606266;
  line-height: 1.6;
}

/* 算法区域 */
.algorithms-section {
  margin-bottom: 60px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.section-header h2 {
  font-size: 32px;
  color: #333;
}

.view-all {
  color: #409EFF;
  text-decoration: none;
  font-size: 16px;
}

.view-all:hover {
  text-decoration: underline;
}

.algorithms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 30px;
}

.algorithm-card {
  background-color: #fff;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.algorithm-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.algorithm-card h3 {
  font-size: 20px;
  margin-bottom: 10px;
  color: #333;
}

.algorithm-type {
  display: inline-block;
  padding: 4px 12px;
  background-color: #ecf5ff;
  color: #409EFF;
  border-radius: 16px;
  font-size: 12px;
  margin-bottom: 15px;
}

.algorithm-desc {
  color: #606266;
  line-height: 1.6;
  margin-bottom: 20px;
  height: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.algorithm-actions {
  display: flex;
  gap: 10px;
}

.detail-btn,
.call-btn {
  flex: 1;
  padding: 8px 16px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 14px;
  text-align: center;
  transition: all 0.3s ease;
}

.detail-btn {
  background-color: #f5f7fa;
  color: #333;
}

.detail-btn:hover {
  background-color: #e4e7ed;
}

.call-btn {
  background-color: #409EFF;
  color: #fff;
}

.call-btn:hover {
  background-color: #66b1ff;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .hero-content h1 {
    font-size: 36px;
  }
  
  .hero-buttons {
    flex-direction: column;
    align-items: center;
  }
  
  .hero-buttons a {
    width: 200px;
    text-align: center;
  }
  
  .features-grid,
  .algorithms-grid {
    grid-template-columns: 1fr;
  }
}
</style>
