<script setup lang="ts">
import { IconifyIcon } from '@vben/icons'

// 视频列表
const videoList = ref([
  {
    id: 1,
    title: '第1步：word文档收集标准',
    url: 'https://english-1313840333.cos.ap-guangzhou.myqcloud.com/question/01_document.mp4',
    description: '请按照视频中的标准，收集题目到word文档',
  },
  {
    id: 2,
    title: '第2步：导入word文档',
    url: 'https://english-1313840333.cos.ap-guangzhou.myqcloud.com/question/02_import.mp4',
    description:
      '将收集好的word文档导入到题库系统，根据系统提示修复文档中的问题',
  },
])

// 当前选中的视频
const currentVideoIndex = ref(0)
const currentVideo = computed(
  () => videoList.value[currentVideoIndex.value] || videoList.value[0],
)

// 切换视频
function switchVideo(index: number) {
  currentVideoIndex.value = index
}
</script>

<template>
  <div class="user-manual g-container">
    <el-tabs type="border-card">
      <el-tab-pane label="视频">
        <h2 class="suggest">
          <span>建议全屏播放</span>
          <IconifyIcon icon="mdi:fullscreen" />
        </h2>
        <div class="video-section">
          <!-- 视频选择器 -->
          <div class="video-selector">
            <el-button
              v-for="(video, index) in videoList"
              :key="video.id"
              :type="currentVideoIndex === index ? 'primary' : 'default'"
              @click="switchVideo(index)"
              class="video-btn"
            >
              {{ video.title }}
            </el-button>
          </div>

          <!-- 视频播放器 -->
          <div class="video-player-container">
            <video
              controls
              :src="currentVideo?.url"
              :key="currentVideo?.id"
              class="video-player"
            >
              您的浏览器不支持视频播放。
            </video>
          </div>

          <!-- 视频描述 -->
          <div class="video-description">
            <!-- <h4>{{ currentVideo?.title }}</h4> -->
            <p>{{ currentVideo?.description }}</p>
          </div>
        </div>
      </el-tab-pane>
      <!-- <el-tab-pane label="文档">正在整理中...</el-tab-pane> -->
    </el-tabs>
  </div>
</template>

<style lang="scss" scoped>
.user-manual {
  .suggest {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
  }

  .video-section {
    padding: 20px;

    h3 {
      margin-bottom: 20px;
      font-size: 18px;
      color: #333;
    }

    .video-selector {
      display: flex;
      gap: 12px;
      justify-content: center;
      margin-bottom: 20px;

      .video-btn {
        min-width: 120px;
      }
    }

    .video-player-container {
      display: flex;
      justify-content: center;
      margin-bottom: 20px;

      .video-player {
        width: 1000px;
        max-width: 100%;
        height: 600px;
        border-radius: 8px;
        box-shadow: 0 4px 12px rgb(0 0 0 / 10%);
      }
    }

    .video-description {
      padding: 15px;
      text-align: center;
      background: #f5f5f5;
      border-radius: 6px;

      h4 {
        margin: 0 0 10px;
        font-size: 16px;
        color: #333;
      }

      p {
        margin: 0;
        font-size: 16px;
        line-height: 1.6;
        color: #333;
      }
    }
  }
}
</style>
