<template>
  <div class="sidebar-container">
    <div class="nav-grid">
      <!-- 首页 -->
      <div class="nav-item" v-for="(items, index) in menuItems" :key="index" @click="handleNavClick(items)">
        <div class="nav-icon">
          <img style=" width:100%;" :src="items.icon">
        </div>
        <div class="nav-text">{{items.name}}</div>
      </div>

      
     
    
    </div>
  </div>
</template>

<script setup>
import { message } from 'ant-design-vue';
import { it } from 'element-plus/es/locales.mjs';
import { ref } from 'vue';
import { useRouter, useRoute } from 'vue-router';

const router = useRouter();
const route = useRoute();
const activeItem = ref('首页'); // 默认激活首页

const props = defineProps(['menuItems']);


// 导航点击处理
const handleNavClick = (item) => {
  console.log('点击了导航项：', item,route);
  try {
    router.push(item.path);
    message.success('跳转：' + item.name);
  } catch (error) {
    console.log('导航项 错误 error', error);
  }

};
</script>

<style scoped>
/* 主容器 */
.main-container {
  background-color: #ffffff;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  padding: 15px;
  width: 100%;
  max-width: 600px;
}

/* 导航网格布局 */
.nav-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  padding: 1rem;
}

/* 导航项 */
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 15px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  box-shadow: #666666 0 0 5px;
  /* background-color: rgb(185, 183, 183); */
}

.nav-item:hover {
  background-color: #f5f5f5;
}

/* 底部导航项 - 个人信息 */
.bottom-nav-item {
  grid-column: span 3; /* 横跨3列 */
  flex-direction: row;
  justify-content: flex-start;
  padding: 12px 15px;
  margin-top: 5px;
}

/* 导航图标 */
.nav-icon {
  width: 24px;
  height: 24px;
  margin-bottom: 8px;
}

.bottom-nav-item .nav-icon {
  margin-bottom: 0;
  margin-right: 15px;
}

/* 导航文本 */
.nav-text {
  font-size: 14px;
  color: #666666;
  text-align: center;
}

.bottom-nav-item .nav-text {
  text-align: left;
}

/* 个人信息右侧线条 */
.nav-line {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: calc(100% - 130px);
  height: 2px;
  background-color: #ffd700;
}

/* 响应式调整 */
@media (max-width: 500px) {
  .nav-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .bottom-nav-item {
    grid-column: span 2;
  }
}
</style>