SingleColumnSkeleton.uvue 1.88 KB
<template>
  <view class="single-column-skeleton-wrap">
    <view v-for="i in count" :key="i" class="skeleton-item">
      <view class="skeleton-shimmer"></view>
      <view class="skeleton-left">
        <view class="skeleton-avatar"></view>
      </view>
      <view class="skeleton-right">
        <view class="skeleton-line skeleton-title"></view>
        <view class="skeleton-line skeleton-subtitle"></view>
      </view>
    </view>
  </view>
</template>

<script setup lang="uts">
defineProps({
  count: {
    type: Number,
    default: 4
  }
});
</script>

<style scoped lang="scss">
.single-column-skeleton-wrap {
  width: 100%;
  box-sizing: border-box;
}

.skeleton-item {
  min-height: 92px;
  background-color: #f5f5f5;
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: row;
  align-items: center;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
  
  &:last-child {
    margin-bottom: 0;
  }
  
  // 流光效果层
  .skeleton-shimmer {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
      90deg,
      transparent 0%,
      rgba(255, 255, 255, 0.3) 50%,
      transparent 100%
    );
    pointer-events: none;
  }
  
  .skeleton-left {
    margin-right: 16px;
    flex-shrink: 0;
    
    .skeleton-avatar {
      width: 52px;
      height: 52px;
      border-radius: 26px;
      background-color: #e0e0e0;
    }
  }
  
  .skeleton-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    
    .skeleton-line {
      height: 14px;
      border-radius: 7px;
      background-color: #e0e0e0;
      margin-bottom: 8px;
      
      &:last-child {
        margin-bottom: 0;
      }
    }
    
    .skeleton-title {
      width: 60%;
      height: 16px;
    }
    
    .skeleton-subtitle {
      width: 40%;
      height: 12px;
    }
  }
}

</style>