<template>
  <div class="user-center">
    <div class="user-sidebar">
      <div class="user-info">
        <el-avatar :size="80" :src="userStore.userInfo.avatar" />
        <h3>{{ userStore.userInfo.name }}</h3>
      </div>
      <el-menu
        :default-active="activeMenu"
        class="user-menu"
        router
      >
        <el-menu-item index="/my/courses">
          <el-icon><Document /></el-icon>
          <span>我的课程</span>
        </el-menu-item>
        <el-menu-item index="/my/profile">
          <el-icon><User /></el-icon>
          <span>个人信息</span>
        </el-menu-item>
      </el-menu>
    </div>
    <div class="user-content">
      <router-view />
    </div>
  </div>
</template>

<script setup>
import { computed } from 'vue'
import { useRoute } from 'vue-router'
import { useUserStore } from '../../stores/user'

const route = useRoute()
const userStore = useUserStore()

const activeMenu = computed(() => route.path)
</script>

<style lang="scss" scoped>
.user-center {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 20px;
  
  @media (max-width: 768px) {
    grid-template-columns: 1fr;
  }
  
  .user-sidebar {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
    overflow: hidden;
    
    .user-info {
      padding: 20px;
      text-align: center;
      border-bottom: 1px solid #eee;
      
      h3 {
        margin-top: 10px;
        font-size: 18px;
      }
    }
    
    .user-menu {
      border-right: none;
    }
  }
  
  .user-content {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
    min-height: 500px;
  }
}
</style> 