<template>
  <el-container class="layout-container">
    <el-aside width="200px">
      <el-menu
        :default-active="activeIndex"
        class="el-menu-vertical"
        @select="handleSelect"
        background-color="#545c64"
        text-color="#fff"
        router
      >
        <el-menu-item index="/monitor">
          <el-icon><Monitor /></el-icon>
          <span>健康监测</span>
        </el-menu-item>
        <el-menu-item index="/statistics">
          <el-icon><TrendCharts /></el-icon>
          <span>数据统计</span>
        </el-menu-item>
        <el-menu-item index="/warning">
          <el-icon><Bell /></el-icon>
          <span>健康预警</span>
        </el-menu-item>
        <el-menu-item index="/news">
          <el-icon><Reading /></el-icon>
          <span>健康资讯</span>
        </el-menu-item>
        <el-menu-item index="/shop">
          <el-icon><ShoppingCart /></el-icon>
          <span>健康商城</span>
        </el-menu-item>
      </el-menu>
    </el-aside>
    
    <el-container>
      <el-header>
        <div class="header-content">
          <h2>智慧健康管理系统</h2>
          <el-dropdown>
            <el-avatar :size="40" src="https://placeholder.com/150" />
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item>个人中心</el-dropdown-item>
                <el-dropdown-item>退出登录</el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
        </div>
      </el-header>
      
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { useRoute } from 'vue-router'
import { Monitor, TrendCharts, Bell, Reading, ShoppingCart } from '@element-plus/icons-vue'

const route = useRoute()
const activeIndex = ref(route.path)

const handleSelect = (key) => {
  console.log('导航到:', key)
}

onMounted(() => {
  activeIndex.value = route.path
})
</script>

<style scoped>
.layout-container {
  height: 100vh;
}

.el-header {
  background-color: #fff;
  border-bottom: 1px solid #dcdfe6;
  padding: 0 20px;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
}

.el-menu-vertical {
  height: 100%;
}

.el-main {
  background-color: #f5f7fa;
}
</style> 