<script setup>
// 骨架屏组件，用于应用初始加载时显示
</script>

<template>
  <transition name="fade">
    <div class="app-skeleton">
      <!-- 顶部导航栏骨架 -->
      <div class="skeleton-header">
        <div class="skeleton-avatar"></div>
        <div class="skeleton-title"></div>
      </div>
      
      <!-- 内容区域骨架 -->
      <div class="skeleton-content">
        <!-- 轮播图骨架 -->
        <div class="skeleton-banner"></div>
        
        <!-- 菜单项骨架 -->
        <div class="skeleton-menu">
          <div class="skeleton-menu-item" v-for="i in 4" :key="i"></div>
        </div>
        
        <!-- 列表项骨架 -->
        <div class="skeleton-list">
          <div class="skeleton-list-item" v-for="i in 3" :key="i">
            <div class="skeleton-list-image"></div>
            <div class="skeleton-list-content">
              <div class="skeleton-list-title"></div>
              <div class="skeleton-list-desc"></div>
              <div class="skeleton-list-price"></div>
            </div>
          </div>
        </div>
      </div>
      
      <!-- 底部导航栏骨架 -->
      <div class="skeleton-tabbar">
        <div class="skeleton-tab-item" v-for="i in 4" :key="i"></div>
      </div>
    </div>
  </transition>
</template>

<style scoped>
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.3s ease;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}

.app-skeleton {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #fff;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 骨架屏动画 */
@keyframes skeleton-loading {
  0% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0 50%;
  }
}

.skeleton-header, .skeleton-avatar, .skeleton-title, .skeleton-banner, 
.skeleton-menu-item, .skeleton-list-image, .skeleton-list-title, 
.skeleton-list-desc, .skeleton-list-price, .skeleton-tab-item {
  background: linear-gradient(90deg, #f2f2f2 25%, #e6e6e6 37%, #f2f2f2 63%);
  background-size: 400% 100%;
  animation: skeleton-loading 1.4s ease infinite;
}

/* 顶部导航栏 */
.skeleton-header {
  height: 44px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #f5f5f5;
}

.skeleton-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

.skeleton-title {
  width: 120px;
  height: 16px;
  margin-left: 12px;
  border-radius: 4px;
}

/* 内容区域 */
.skeleton-content {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
}

.skeleton-banner {
  width: 100%;
  height: 150px;
  border-radius: 8px;
  margin-bottom: 20px;
}

/* 菜单项 */
.skeleton-menu {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
}

.skeleton-menu-item {
  width: 60px;
  height: 60px;
  border-radius: 8px;
}

/* 列表项 */
.skeleton-list-item {
  display: flex;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid #f5f5f5;
}

.skeleton-list-image {
  width: 80px;
  height: 80px;
  border-radius: 4px;
  flex-shrink: 0;
}

.skeleton-list-content {
  flex: 1;
  margin-left: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.skeleton-list-title {
  height: 16px;
  width: 80%;
  border-radius: 4px;
  margin-bottom: 8px;
}

.skeleton-list-desc {
  height: 12px;
  width: 60%;
  border-radius: 4px;
  margin-bottom: 8px;
}

.skeleton-list-price {
  height: 16px;
  width: 40%;
  border-radius: 4px;
}

/* 底部导航栏 */
.skeleton-tabbar {
  height: 50px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  border-top: 1px solid #f5f5f5;
  padding: 0 16px;
}

.skeleton-tab-item {
  width: 24px;
  height: 24px;
  border-radius: 4px;
}
</style> 