Просмотр исходного кода

fix: RecommendedSection无数据时显示空状态而非隐藏整个组件

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
liaoxg 3 месяцев назад
Родитель
Сommit
2956efc14a
1 измененных файлов с 14 добавлено и 3 удалено
  1. 14 3
      cfc-frontend/components/RecommendedSection.vue

+ 14 - 3
cfc-frontend/components/RecommendedSection.vue

@@ -1,11 +1,11 @@
 <template>
-  <view class="recommended-section" v-if="items && items.length > 0">
+  <view class="recommended-section">
     <view class="section-header">
       <text class="section-icon">✨</text>
       <text class="section-title">为你推荐</text>
-      <text class="section-more" v-if="hasMore" @click="$emit('more')">更多 ›</text>
+      <text class="section-more" v-if="hasMore && items && items.length > 0" @click="$emit('more')">更多 ›</text>
     </view>
-    <scroll-view class="scroll-x" scroll-x show-scrollbar="false">
+    <scroll-view class="scroll-x" scroll-x show-scrollbar="false" v-if="items && items.length > 0">
       <view class="card-list">
         <view
           class="card-item"
@@ -25,6 +25,9 @@
         </view>
       </view>
     </scroll-view>
+    <view class="empty-state" v-else>
+      <text class="empty-text">暂无推荐内容</text>
+    </view>
   </view>
 </template>
 
@@ -166,4 +169,12 @@ export default {
   -webkit-line-clamp: 2;
   overflow: hidden;
 }
+.empty-state {
+  padding: 40rpx 0;
+  text-align: center;
+}
+.empty-text {
+  font-size: 26rpx;
+  color: #ccc;
+}
 </style>