Ver Fonte

fix: 首页知识库

lxf há 2 semanas atrás
pai
commit
1ff0c182e8
1 ficheiros alterados com 22 adições e 2 exclusões
  1. 22 2
      src/views/old_mini/home/components/knowledgeCard.vue

+ 22 - 2
src/views/old_mini/home/components/knowledgeCard.vue

@@ -13,7 +13,7 @@
                 更多<el-icon class="more-icon"><ArrowRight /></el-icon>
             </div>
         </div>
-        <div class="knowledge-content">
+        <div class="knowledge-content" v-if="activeKnowledgeId === 7">
             <div
                 class="knowledge-item"
                 @click="handleBannerClick(item.id)"
@@ -28,11 +28,26 @@
             </div>
             <div class="no-data" v-if="knowledgeList.length === 0">暂无数据</div>
         </div>
+        <div class="knowledge-content" v-else>
+            <div
+                class="knowledge-item"
+                @click="handleBannerClick(item.postInfo?.postId)"
+                v-for="(item, index) in knowledgeList"
+                :key="index"
+            >
+                <img class="thumb" :src="item.postInfo?.media?.[0]" alt="" />
+                <div class="card-body-left">
+                    <div class="title van-multi-ellipsis--l2">{{ item.postInfo?.title }}</div>
+                    <div class="date">{{ formatDate(item.createTime) }}</div>
+                </div>
+            </div>
+            <div class="no-data" v-if="knowledgeList.length === 0">暂无数据</div>
+        </div>
     </div>
 </template>
 
 <script setup>
-import { onMounted, ref } from "vue";
+import { onMounted, ref, watch } from "vue";
 import { useRouter } from "vue-router";
 import { useStore } from "vuex";
 
@@ -69,6 +84,11 @@ onMounted(() => {
     // 默认 topicId 首次进入时请求一次
     getKnowledgeList();
 });
+watch(store.state.home.gardenId, (newGardenId) => {
+    if(newGardenId) {
+        getKnowledgeList();
+    }
+});
 
 const formatDate = (dateString) => {
     if (!dateString) return "";